I need help scripting a Turnstile

Hello,
I am currently creating a roleplay game and I am scripting a train system for it. I have the whole system down but I am struggling to figure out how to script the rotation of the turnstile.

I want it to rotate as it would however I’m not sure how to do it so that it doesn’t do this:
image

I recommend tweening its orientation.

Sorry to bother you but i cannot figure out how to do it, please may you give me an example

I hope this is good enough.

TweenService = game:GetService("TweenService")

spininfo = TweenInfo.new(20,Enum.EasingStyle.Linear) -- 20 is the rotation time

Spin1 = TweenService:Create(script.Parent,spininfo,{CFrame = script.Parent.CFrame * CFrame.Angles(0,math.rad(120),0)}) -- you can change the X Y Z rotations here

Spin1:Play()

Eh, CFrame is better practice as the use of orientation is less abudant.

Use a HingeConstraint | Roblox Creator Documentation on the turnstile and a plate on the floor with a script that rotates the HingeConstraint 120 degrees each time the plate is touched.

1 Like