Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how can i rotate a car with a script?

if there a way i could rotate a car with a script. so basically if the car was upside down and players had a gui so if they clicked the gui it will rotate the car and rotate it so it is on its wheels and driveable again. i made a script to make it kinda move a little bit into the air if it gets stuck but how can i make it rotate if its upside down?

local ting = 0
function onclick()
	if ting == 0 then
		ting = 1
		local carseat = script.Parent.Parent.CarSeat.Value
		local car = carseat.Parent.Parent
		car:TranslateBy(Vector3.new(0,15,0))
		wait(0.2)
		ting = 0
	end
end

1 answer

Here's a function you can implement. It turns the car over using BydyGyro

local function upright()
    local seat = script.Parent.Parent.CarSeat --Assuming the carseat is a part
    local bg = Instance.new("BodyGyro",seat) --creates a bodygyro to flip the car upright
    bg.MaxForce = Vector3.new(4000000,4000000,4000000)
    bg.P = 3000
    game.Debris:AddItem(bg,3.5)
end

--call this function in your script where you want it to flip the car over

2 comments

0

doesnt flip the car if it is upside down

0

Are you calling the function? Try increasing the "P" value.

This discussion is preserved as it was. New answers, comments, and votes are closed.