Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help fixing a model rotating script?

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)

1 comment

0

can you show what Model do?

1 answer

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)

2 comments

0

It's still not working, where do I put the script because I tried putting it in the car and part.

0

What's the rest of your script?

This discussion is preserved as it was. New answers, comments, and votes are closed.