i tried something what is name Gtae that it open's or i will make a script that will activate it but it isn't working? it just print no gate if i touch the gate with my mouse? The Gate is a Union but it's named Gate
script.Parent.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() if mouse.Target and mouse.Target.Parent.Name == "Gate" then if mouse.Target.Open == false then mouse.Target.Open = true wait(3) elseif mouse.Target.Open == true then mouse.Target.Open = false wait(3) end else print("no gate") end end) end)
This is a quite easy to fix mistake. Just add a .Name to the end.
script.Parent.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() if mouse.Target.Parent.Name == "Gate" then mouse.Target.CFrame = CFrame.new(-2,0,0) else print("no gate") end end) end)
You are trying to make a object equal to a string.
does the target "gate" have a boolvalue "Open" and "Close"? because a union on its own, does not have a boolean that is named Open and close...
right now, the script looks voor Gate.Open, which is not existant so nil, and moves to the elseif. In the elseif it looks for Gate.Close, which is also non-existant == nil, and moves to the else case, ergo "no gate".
What you want is a boolvalue attached to the Gate that toggled to open and close it. It should be named "Open". A different script could in its place check for a value change and move the door accordingly.