Im trying to make a script that randomly "pushes" a car in a random direction.
The problem is, i don't know how to get the vehicle that the player is driving.
btw, this is supposed to work in a server running "race" Gamemode.
server.lua
addEvent("forceButtonInfo",true)
function forceButtonServer(playerName) --Connected with a gui button in client.lua
local targetPlayer = getPlayerFromName ( playerName )
if ( targetPlayer ) then
outputChatBox("Player Found!") --This actually appears in the chatbox so the function is working
setElementVelocity ( targetPlayer,math.random(-100,100), math.random(-100,100),math.random(-100,100) ) --This doesnt work
else
outputChatBox("Player not Found")
end
end
addEventHandler ( "forceButtonInfo", getRootElement(), forceButtonServer )
Sorry if theres any typo, im not a native english speaker.