Rotate Vehicle On Click Script

I want to make a button in the workspace that when clicked, changes the orientation of the model that the vehicle seat is in. The player would be in the vehicle seat.

My Workspace:
Script - Roblox Studio 27_09_2022 7_48_36 PM

2 Likes

Your question is a little vague, It would help if you could be more specific in what you were asking for, are you wanting us to help you with the entire script? (Detecting button click, Getting the model, changing the orientation)

You can detect button clicks by using the .MouseClick event for ClickDetectors.

One option to changing the rotation/orientation of a model is utilizing the Model:PivotTo method.

I’d be more than happy to help you further if you could specify what you need.

I need help with the whole script.

It would help if you were educated on the very basics which it seems like you may not be, learning the basics might be a good place to start before attempting to do anything. It’s always more ideal to make an attempt yourself first before coming here, I’m not going to spoonfeed you the entire script, as I said, I don’t mind answering more specific questions, but here is an brief example based on what you have provided:

local Part = script.Parent -- Referencing the part that the script is inside of
local ClickDetector = Part:WaitForChild('ClickDetector') -- Referencing the ClickDetector

-- You would need to reference the model here, I can't give you this, so I've done an example
local Model = workspace.Car

-- Listening for when the button was clicked by someone.
ClickDetector.MouseClick:Connect(function(PlayerWhoClicked)
   Model:PivotTo( CFrameGoesHere ) -- You can change the model around like this by using CFrame.Angles etc
end)

How can I make the vehicle that the player is driving the, ‘Model’ (instead of workspace.Car), since there would be multiple vehicles.

If I’m not mistaken, you could use the Humaniod’s SeatPart property to get the Seat part, (Assuming roblox sets this automatically?)

Then with that reference to the seat, you can climb the ancestory to get the model.

Just mentioning, the rules of this category say you can’t explicitly ask someone to just… make an entire script for you.

You could use PlayerWhoClicked.Character to get the player’s humanoid from the function made above, and then follow @sI0_th’s other reply.

Just like was said earlier,

It doesn’t seem you are too knowledgeable of scripting and it may help if before jumping into the deep end, you could do some basic scripting that you can learn easily? There are tons of resources on the devfourms and on roblox’s own onboarding that would be perfect for you.

1 Like