My on-click door script won't stay in place. Every time I click on it, it goes on the top of the building. Here's the script I used:
local open = false; script.Name = "Clickable Door Script"; -- On the assumption that this is that script script.Parent.ClickDetector.MouseClick:connect(function() if not open then -- Checks if closed script.Parent.Rotation = Vector3.new(0, 110, 0); open = true; else -- If open script.Parent.Rotation = Vector3.new(0, 0, 0); open = false; end end)
I was then told to use the script below, but every time I run it, the output box says, "12:56:47.119 - Workspace.Door.Clickable Door Script:9: bad argument #3 to 'Rotation' (Vector3 expected, got userdata)"
local open = false; -- so glad you declare variables efficiently script.Name = "Clickable Door Script"; -- On the assumption that this is that script script.Parent.ClickDetector.MouseClick:connect(function() if not open then -- Checks if closed script.Parent.Rotation = CFrame.Angles (0, 110, 0); open = true; else -- If open script.Parent.Rotation = CFrame.Angles (0, 0, 0); open = false; end end)
I kind of agree with the 2. script, but it's still very wrong. Anyway, you shouldn't set rotation, use it as a read only property.
local open = false; local originalCF = script.Parent.CFrame script.Name = "Clickable Door Script"; -- On the assumption that this is that script script.Parent.ClickDetector.MouseClick:connect(function() if not open then -- Checks if closed script.Parent.CFrame = originalCF * CFrame.Angles(0, math.rad(110), 0) * CFrame.new(script.Parent.Size.x/4, 0, script.Parent.Size.x/2) open = true; else -- If open script.Parent.CFrame = originalCF; open = false; end end)