Stop The Function

thanks guys for ur time i solve the problem from ur idea it works hehe

1 Like

You need to put a solution if it was someone that solved it.

Nice!

Can you share what you ended up doing?

local playersService = game:GetService("Players")
local repstorage = game:GetService("ReplicatedStorage")
local timer = repstorage:WaitForChild("Value"):WaitForChild("Timer")
local maps = repstorage:WaitForChild("Maps"):GetChildren()

while task.wait() do
	for i = 10,0,-1 do
		timer.Value = "".. i
		task.wait(1)
	end

	local rand = math.random(1,#maps)
	local map = maps[rand]:Clone()
	map.Parent = workspace:WaitForChild("Map")
	local players = playersService:GetPlayers()
	
	for i = 1,#players do
		if players[i].Character ~= nil then
			local spawns = map:WaitForChild("Spawn"):GetChildren()
			local teleporter = math.random(1,#spawns)
			players[i].Character:MoveTo(spawns[teleporter].Position)
			players[i].Character.Parent = workspace:WaitForChild("Ingame")
		end
	end	

	local roundLength = 50
	local roundType = ""
	
	if map:FindFirstChild("Banana") then
		roundType = "Banana"
		roundLength += 30
	elseif map:FindFirstChild("Mango") then
		roundType = "Mango"
		roundLength -= 10
	end

	coroutine.wrap(function()
		if roundType == "Banana" then
			local players = playersService:GetPlayers()
			for i = 1,#players do
				if players[i].Character ~= nil then
					players[i].Chatted:Connect(function(msg)
						if string.lower(msg) == "banana" then
							print("Im an epic banana")
						end
					end)
					players[i].Chatted:Disconnect()
				end	
			end
		end
	end)

	coroutine.wrap(function()
		if roundType == "Mango" then
			local players = game.Players:GetChildren()
			for i = 1,#players do
				if players[i].Character ~= nil then
					players[i].Chatted:Connect(function(msg)
						if string.lower(msg) == "mango" then
							print("Im an epic mango")
						end
					end)
					players[i].Chatted:Disconnect()
				end	
			end
		end
	end)

	repeat
		roundLength -= 1
		timer.Value = ""..roundLength
		task.wait(1)
	until
	roundLength == 0 and roundType == "Banana" or
		#workspace.Ingame:GetChildren() == 0 and roundType == "Banana" or -- Banana
		----------------------------------------------------------------------------------------------
		roundLength == 0 and roundType == "Mango" or
		#workspace.Ingame:GetChildren() == 0 and roundType == "Mango" -- Mango

	task.wait()
	roundType = ""
	local players = game.Players:GetChildren()
	for i = 1,#players do
		if players[i].Character ~= nil then
			players[i]:LoadCharacter()
			map:Destroy()
		end
	end	
end

Relatively simple fix, nice script by the way.

1 Like

the debounce it works fine and the problem solved idk if i wanna put solution

I’m curious, what exactly are you debouncing?

Can you show the working code if you don’t mind? (I’m not sure you know what a debounce is)