mehdi koocholo Posted June 10, 2023 Share Posted June 10, 2023 hi guys How can I move a car without a player in that car? Link to comment
FLUSHBICEPS Posted June 10, 2023 Share Posted June 10, 2023 (edited) setElementVelocity Edited June 10, 2023 by FLUSHBICEPS Link to comment
Jesseunit Posted June 13, 2023 Share Posted June 13, 2023 It depends on how you want to 'move' the car. You want the car to change to a completely different position/location? Use setElementPosition. If you want to change the cars' speed/velocity use setElementVelocity. Link to comment
FallenGod Posted August 4, 2023 Share Posted August 4, 2023 Hi I Hope I Can Help You --== Script By ErroR (FullOffeD) ==-- -- Set the target position local targetX, targetY, targetZ = 100, 200, 10 -- Create the vehicle local vehicle = createVehicle(411, 0, 0, 0) -- Get Distance function getDistance(x1, y1, z1, x2, y2, z2) return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2 + (z2 - z1) ^ 2) end function moveVehicleToTarget() local x, y, z = getElementPosition(vehicle) local distance = getDistance(x, y, z, targetX, targetY, targetZ) -- Speed To Move local speed = 5 if distance > 1 then local directionX = (targetX - x) / distance local directionY = (targetY - y) / distance local directionZ = (targetZ - z) / distance setElementPosition(vehicle, x + directionX * speed, y + directionY * speed, z + directionZ * speed) addEventHandler("onClientRender", root, moveVehicleToTarget) else removeEventHandler("onClientRender", root, moveVehicleToTarget) end end Use Thats Code To Move Vehicle To Your Custom x,y,z Without Player Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now