Hello,
Recently I have been trying to make a door which slides up and down when you press a button, I am trying to get it so the script looks for the position of the door and if it is equal to 190.253, 8.125, 67.725
, then make the door open by sliding up. But on the 6th line, it comes up with the error of
Workspace.Model.LeftDoor.Button.Script:6: attempt to call global 'Vector3' (a table value)
local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor local Sound = script.Parent.Sound script.Parent.ClickDetector.MouseClick:connect (function() if LeftDoor.CFrame == (Vector3(190.253, 8.125, 67.725)) then for i = 1,14 do LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector3(0,1,0)) wait() end Sound.Playing = false Sound.Playing = true else if LeftDoor.Position == (Vector3(190.253, 22.125, 67.725)) then for i = 1,14 do LeftDoor.CFrame = CFrame.new(LeftDoor.Position - Vector3(0,1,0)) wait() end Sound.Playing = false Sound.Playing = true end end end)
Does anybody know a way of fixing this?
This should work
local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor local Sound = script.Parent.Sound script.Parent.ClickDetector.MouseClick:connect (function() if LeftDoor.CFrame == Vector3(190.253, 8.125, 67.725)) then for i = 1,14 do LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector3(0,1,0)) wait() end Sound.Playing = false Sound.Playing = true else if LeftDoor.Position == Vector3.new(190.253, 22.125, 67.725)) then for i = 1,14 do LeftDoor.CFrame = CFrame.new(LeftDoor.Position - Vector3(0,1,0)) wait() end Sound.Playing = false Sound.Playing = true end end end)
I've created a new script for it and it works, kind of.
local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor local Sound = script.Parent.Sound local debounce = false local door = false script.Parent.ClickDetector.MouseClick:connect(function() if not debounce then debounce = true if not door then door = true Sound.Playing = false Sound.Playing = true for i = 1,14 do LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector3.new(0,1,0)) wait() end debounce = false else if door then door = false Sound.Playing = false Sound.Playing = true for i = 1,14 do LeftDoor.CFrame = CFrame.new(LeftDoor.Position - Vector3.new(0,1,0)) wait() end debounce = false end end end end)
Its a bit more but it works