Hello. I made a script that moves the whole model when you click it using it's PrimaryPart CFrame. But for some reason, I got "Attempt to index nil with 'CFrame' " error in the output. What's the source of error that I get?
function onClick()
script.Parent.ClickDetector.MaxActivationDistance=0
for i = 1,20 do
script.Parent.Parent.Parent:SetPrimaryPartCFrame(script.Parent.Parent.Parent.PrimaryPart.CFrame + CFrame.new(Vector3.new(0,.10,0)))
wait()
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClick)

1 comment
Thank you so much, that kinda helped but it actually wasn't a sollution for my issue, It gave me the same error. Actually, it was my bad. I just realized line 4 was actually wrong. I added the model name after .Parent property "ExitDoor" which is supposed to move (script.Parent.Parent.Parent.ExitDoor.PrimaryPart.CFrame). I'll still accept that as a sollution, thank you so much.