Issue
When the clickdetector is activated, the position of the Tram model changes as well as the orientation. I wan’t just the orientation to change when I use PivotTo.
Code
local newCF = CFrame.Angles(0, 0, 0) -- Rotate by 180 deg around the Y axis
function Click(Player)
workspace:FindFirstChild("Tram"..Player.Name):PivotTo(newCF)
if Player.Character then
wait(1)
Player.Character:MoveTo(workspace:FindFirstChild("Tram"..Player.Name).One.VehicleSeat.Position)
end
end
script.Parent.ClickDetector.MouseClick:Connect(Click)
local newCF = CFrame.Angles(0,math.pi,0) --Rotate 180 degrees relative to the tram, on the Y axis.
function Click(Player)
local tram = workspace:FindFirstChild(("Tram%s"):format(Player.Name))
if not tram then return end
tram:PivotTo(tram:GetPivot()*newCF)
if Player.Character then
task.wait(.5)
Player.Character:MoveTo(tram.One.VehicleSeat.Position)
end
end)
script.Parent.ClickDetector.MouseClick:Connect(Click)
I cleaned up your code a little bit as well. Try using this script. It will rotate it relative to the tram’s current rotation.
You should always mark the post that solved it, as ‘solution’ or at least say how you solved it, so if others have the same or similar issue it can help them out.