I have a problem: I made this door to tween and the only time it will tween is when the tool is unequipped. It’s still in my inventory, it’s just that it only allows the door to tween when I don’t have the tool in my hand. So when I equip it, the door won’t tween. Can you help me fix this weird issue?
Here’s the local script in starter GUI:
local access = game.ReplicatedStorage.Events:WaitForChild("AccessGranted")
access.OnClientEvent:Connect(function()
openDoor:Play()
wait(3)
closeDoor:Play()
end)
And the regular script inside the part:
local accessGranted = game.ReplicatedStorage.Events:WaitForChild("AccessGranted")
local toggleBeam = game.ReplicatedStorage.Events:WaitForChild("ToggleBeam")
local message = game.ReplicatedStorage.Events:WaitForChild("Message")
local door = workspace.Door
script.Parent.ProximityPrompt.Triggered:Connect(function(player)
local char = player.Character
local tool = player.Backpack:FindFirstChildOfClass("Tool")
if tool and tool.Name == "Key" then
accessGranted:FireClient(player)
print("Access granted!")
message:FireClient(player, "You have unlocked the first maze!")
script.Parent.Parent.Screen.SurfaceGui.TextLabel.Text = "ACCESS GRANTED"
wait(2)
script.Parent.Parent.Screen.SurfaceGui.TextLabel.Text = ""
wait(2)
message.Value = ""
else
print("Access denied. Comeback with the key!")
script.Parent.Parent.Screen.SurfaceGui.TextLabel.Text = "ACCESS DENIED"
wait(2)
script.Parent.Parent.Screen.SurfaceGui.TextLabel.Text = ""
end
end)
And just in case, here’s the previous regular script:
local accessGranted = game.ReplicatedStorage.Events:WaitForChild("AccessGranted")
local toggleBeam = game.ReplicatedStorage.Events:WaitForChild("ToggleBeam")
local message = game.ReplicatedStorage.Events:WaitForChild("Message")
local door = workspace.Door
script.Parent.ProximityPrompt.Triggered:Connect(function(player)
local char = player.Character
local tool = player.Backpack:FindFirstChild("Key")
if tool then
accessGranted:FireClient(player)
print("Access granted!")
message:FireClient(player, "You have unlocked the first maze!")
script.Parent.Parent.Screen.SurfaceGui.TextLabel.Text = "ACCESS GRANTED"
wait(2)
script.Parent.Parent.Screen.SurfaceGui.TextLabel.Text = ""
wait(2)
message.Value = ""
else
print("Access denied. Comeback with the key!")
script.Parent.Parent.Screen.SurfaceGui.TextLabel.Text = "ACCESS DENIED"
wait(2)
script.Parent.Parent.Screen.SurfaceGui.TextLabel.Text = ""
end
end)