Im trying to make a keyfob where you click and it opens 2 gates but it isnt working. Some important infomation would be that the tool is a team tool that is controlled by a script. Any assistance would be grateful.
local gates = workspace.policegates
local tool = script.Parent.Parent
tool.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
if gates.Barrier1.Motor.DesiredAngle == 0 then
gates.Barrier1.Motor.DesiredAngle = 1.57
gates.Barrier.Motor.DesiredAngle = 1.57
else
gates.Barrier1.Motor.DesiredAngle = 0
gates.Barrier.Motor.DesiredAngle = 0
end
end)
end)
I’m assuming this is a server scipt, in which case you can’t reference the Mouse object. As @KreatorKols mentioned, you should use the .Activated event instead:
local gates = workspace.policegates
local tool = script.Parent.Parent
tool.Activated:Connect(function()
if gates.Barrier1.Motor.DesiredAngle == 0 then
gates.Barrier1.Motor.DesiredAngle = 1.57
gates.Barrier.Motor.DesiredAngle = 1.57
else
gates.Barrier1.Motor.DesiredAngle = 0
gates.Barrier.Motor.DesiredAngle = 0
end
end)