Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help fixing a model rotating script?

Asked by 3 years ago

I have a script that is meant to rotate a model (90°) when that model touches a certain part. I'm not sure if I put the script for this in that part or somewhere in the model like the primary part. Can someone please tell me how to fix/where to put this?

Model.PrimaryPart.Touched:Connect(function(hit)
    if hit == Part then
        Model:SetPrimaryPartCFrame(Model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(angleToRotate), 0))
    end
end)
0
can you show what Model do? mattew0917 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

The primary part load when you connected the touch event. So you'll need to use WaitForChild.

Model:WaitForChild("PrimaryPart").Touched:Connect(function(hit)
    if hit == Part then
        Model:SetPrimaryPartCFrame(Model:WaitForChild("PrimaryPart").CFrame * CFrame.Angles(0, math.rad(angleToRotate), 0))
    end
end)
0
It's still not working, where do I put the script because I tried putting it in the car and part. DJTwisted_2 0 — 3y
0
What's the rest of your script? rayhansatria 142 — 3y
Ad

Answer this question