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)
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)