Hello, I am making a plane but can’t seem to figure out how to make a propeller rotate. I need it to rotate when a player hits a certain key. Also how I would implement script into a mesh. I’m very new to scripting and would like help. Lastly, the propeller is a model. Thanks.
1 Like
You can rotate the Primary Part of the model (You’ll have to set the primary part first, of cours).
Then, do do it on press of a key, you have to use UserInputService. It would end up something like this:
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(inputObject)
if inputObject.UserInputType == Enum.UserInputType.Keyboard then -- check if input was from keyboard
local value = inputObject.KeyCode -- what key did they press?
if value == Enum.KeyCode.E then -- when they press E key
--Rotate the model
TweenService = game:GetService("TweenService")
spininfo = TweenInfo.new(2,Enum.EasingStyle.Linear)
Spin1 = TweenService:Create(script.Parent.PrimaryPart,spininfo,{CFrame = script.Parent.CFrame * CFrame.Angles(0,math.rad(120),0)})
Spin1:Play()
end
end
end)
For this example, you have a localscript inside the vehicle that detects userinput, and tweens the part accordingly. As long as the player has network ownership of the vehicle (by sitting in it, they will have network ownership), this will replicate to everyone.
Ok, I will try that. Thank you very much!