I have two scripts, one is a localscript and one is a normal script. When a button is pressed, the localscript fires an event, which goes to the script. When i fire the event the first time, it works fine, but when I fire the event another time, it doesn't work. I have three very similar scripts, that all deal with a value named "Seconds" and a team named "Playing". Here are my scripts:

LocalScript #1:

local debounce = false
local seconds = game.ReplicatedStorage.Seconds
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("EndRound")
function leftClick()
	if debounce == false then
		if seconds.Value > 0 then
		print("Left mouse clicked cool kid's end round button")
		debounce = true
		event:FireServer()
		script.Parent.Text = "(15)"
		wait(1)
		script.Parent.Text = "(14)"
		wait(1)
		script.Parent.Text = "(13)"
		wait(1)
		script.Parent.Text = "(12)"
		wait(1)
		script.Parent.Text = "(11)"
		wait(1)
		script.Parent.Text = "(10)"
		wait(1)
		script.Parent.Text = "(9)"
		wait(1)
		script.Parent.Text = "(8)"
		wait(1)
		script.Parent.Text = "(7)"
		wait(1)
		script.Parent.Text = "(6)"
		wait(1)
		script.Parent.Text = "(5)"
		wait(1)
		script.Parent.Text = "(4)"
		wait(1)
		script.Parent.Text = "(3)"
		wait(1)
		script.Parent.Text = "(2)"
		wait(1)
		script.Parent.Text = "(1)"
		wait(1) 
		script.Parent.Text = "End Round"
		debounce = false
		else script.Parent.Text = "bruh round is already over"
			debounce = true
			wait(1)
			debounce = false
			script.Parent.Text = "End Round"
		end
	end
end
script.Parent.MouseButton1Click:Connect(leftClick)

Script #1:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = Instance.new("RemoteEvent", ReplicatedStorage)
event.Name = "EndRound"
local Teams = game:GetService("Teams")
local Players = game:GetService("Players")

local function EndRoundNOW()
	local seconds = game.ReplicatedStorage.Seconds
	for i,v in pairs(Players:GetPlayers()) do
	    if v.Team == Teams["Playing"] then
	        pcall(function()
	            v.Character:BreakJoints()
	        end)
	    end
	end
	print("someone wants to end the round")
	seconds.Value = 0
end
 
event.OnServerEvent:Connect(EndRoundNOW)

LocalScript #2:

local debounce = false
local seconds = game.ReplicatedStorage.Seconds
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("EndRound3")
function leftClick()
	if debounce == false then
		if seconds.Value > 0 then
		print("Left mouse clicked cool kid's end round button")
		debounce = true
		event:FireServer()
		script.Parent.Text = "(5)"
		wait(1)
		script.Parent.Text = "(4)"
		wait(1)
		script.Parent.Text = "(3)"
		wait(1)
		script.Parent.Text = "(2)"
		wait(1)
		script.Parent.Text = "(1)"
		wait(1) 
		script.Parent.Text = "End Round"
		debounce = false
		else script.Parent.Text = "come on dude"
			debounce = true
			wait(1)
			debounce = false
			script.Parent.Text = "End Round"
		end
	end
end
script.Parent.MouseButton1Click:Connect(leftClick)

Script #2:

local seconds = game.ReplicatedStorage.Seconds
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = Instance.new("RemoteEvent", ReplicatedStorage)
event.Name = "EndRound3"
local Teams = game:GetService("Teams")
local Players = game:GetService("Players")
	


	 
	

local function EndRoundNOW()
	for i,v in pairs(Players:GetPlayers()) do
	    if v.Team == Teams["Playing"] then
	        pcall(function()
	            v.Character:BreakJoints()
	        end)
	    end
	end
	print("someone wants to end the round")
	seconds.Value = 0
end
 
event.OnServerEvent:Connect(EndRoundNOW)

LocalScript #3:

local debounce = false
local seconds = game.ReplicatedStorage.Seconds
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("EndRound2")
function leftClick()
	if debounce == false then
		if seconds.Value > 0 then
		print("Left mouse clicked cool kid's end round button")
		debounce = true
		event:FireServer()
		script.Parent.Text = "(5)"
		wait(1)
		script.Parent.Text = "(4)"
		wait(1)
		script.Parent.Text = "(3)"
		wait(1)
		script.Parent.Text = "(2)"
		wait(1)
		script.Parent.Text = "(1)"
		wait(1) 
		script.Parent.Text = "No-Playing E.R."
		debounce = false
		else script.Parent.Text = "come on dude"
			debounce = true
			wait(1)
			debounce = false
			script.Parent.Text = "No-Playing E.R."
		end
	end
end
script.Parent.MouseButton1Click:Connect(leftClick)

Script #3:

local seconds = game.ReplicatedStorage.Seconds
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = Instance.new("RemoteEvent", ReplicatedStorage)
event.Name = "EndRound2"
local Teams = game:GetService("Teams")
local Players = game:GetService("Players")
	


	 
	

local function EndRoundNOW()
	print("someone wants to end the round")
	seconds.Value = 0
end
 
event.OnServerEvent:Connect(EndRoundNOW)

Once I press one of the buttons and set seconds to 0, doing it again doesn't work. Any suggestions?

1 comment

1

The first sciript has a 15 sec cooldown, and other ones 5 sec each. Is that not a desired effect?