So, I'm making a toggle-able ClickDetector script, where the player who clicks the part will start doing x. Once they click the part again, they will no longer be doing x.
I need to know how I can make no other player be able to do x while a player is already doing it.
local chat = game:GetService('Chat')
local Players = game:GetService('Players')
local talker1 = workspace.talker1.ClickDetector
local talker2 = workspace.talker2.ClickDetector
local vacant = workspace.talker1.boolValue
local repStorage = game:GetService('ReplicatedStorage')
local toggleMovement = repStorage:WaitForChild('toggleMovement')
talker1.MouseClick:Connect(function(playerWhoClicked)
if talker1.Parent.BrickColor == BrickColor.Red() then
talker1.Parent.BrickColor = BrickColor.Black()
else
talker1.Parent.BrickColor = BrickColor.Red()
end
toggleMovement:FireClient(playerWhoClicked)
local findBoolOne = playerWhoClicked.Character.Humanoid:FindFirstChild('talkerBoolOne')
Player = playerWhoClicked
if not findBoolOne then
local talkerBoolOne = Instance.new("BoolValue", playerWhoClicked.Character.Humanoid)
talkerBoolOne.Name = "talkerBoolOne"
end
talkerOne = playerWhoClicked.Character.Humanoid:FindFirstChild('talkerBoolOne')
playerWhoClicked.Character.Humanoid.Died:Connect(function()
talkerOne.Value = false
end)
if talkerOne.Value == false then
talkerOne.Value = true
else
talkerOne.Value = false
end
end)

1 comment
add a debounce