If function literally plays even when the prompt is not correct

I got a script. which is a timer for my skating minigame.
Countdown plays. But literally the next second the IF TIMER <= 0 THEN PLAYS.
Like… WHAT? is this roblox or something but this happened to me alot, i can’t fix it at all.
Please help.

Script

game.ReplicatedStorage.Cat.Timer.OnServerEvent:Connect(function(Player)
	local localpart1 = game:GetService("ReplicatedStorage").Skateboard:Clone()
	local Players = game.Players:GetPlayers()
	local repi = game:GetService("ReplicatedStorage")
	localpart1.Parent = workspace
	local timer = 15
	local completedminigame = false
	local BadgeService = game:GetService("BadgeService")
	print("variable")
	local Players = game:GetService("Players")
	print("variable")
	local textmaker = Player.PlayerGui.NewDialouge.TextLabel
	print("variable")
	local ts = game:GetService("TweenService")
	print("variable")
	local ti1 = TweenInfo.new(2,Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false)
	print("variable")
	local ti2 = TweenInfo.new(1,Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false)
	print("variable")
	local sound = Player.PlayerGui.MainMenu.poo.SoundPlayer.Main
	print("variable")
	local image = Player.PlayerGui.Collected.Winner
	print("variable")
	local currentrotation = image.ImageLabel.Rotation
	print("variable")
	print("variable")

	local db = false
	print("variable")

	local Part = script.Parent
	print("variable")
	print("variable")

	local debounce = true
	print("variable")
	local ab = false
	for i = 120, 0, -1 do
		if timer > 0 then
			if completedminigame == false then
				timer = timer - 1
				textmaker.Text = timer
				wait(1)
			else
				for i,v in ipairs(workspace.CurrentCamera:GetChildren()) do
					v:Destroy()
				end
				textmaker.Text = ""
				Player.Character:WaitForChild("Board"):Destroy()
				game:GetService("StarterGui"):SetCore("ResetButtonCallback", true)
				wait(1)
				textmaker.Text = ""

			end
		elseif timer <= 0 then
			print("Minigame failed")
			for i,v in ipairs(workspace.CurrentCamera:GetChildren()) do
				v:Destroy()
			end
		end
		textmaker.Text = ""
		Player.Character:WaitForChild("Board"):Destroy()
		game:GetService("StarterGui"):SetCore("ResetButtonCallback", true)
		Player.Character:WaitForChild("Humanoid").Health = 0
		wait(1)
		textmaker.Text = ""
	end
end)

LocalScript

local Player = game.Players.LocalPlayer
local localpart1 = game:GetService("ReplicatedStorage").Skateboard:Clone()
local Players = game.Players:GetPlayers()
local repi = game:GetService("ReplicatedStorage")
localpart1.Parent = workspace
local timer = 15
local completedminigame = false
local BadgeService = game:GetService("BadgeService")
print("variable")
local Players = game:GetService("Players")
print("variable")
local cat = Player.PlayerGui.BananaPedia.GUI.Structure.ScrollingFrame.SkaterCat
local textmaker = Player.PlayerGui.NewDialouge.TextLabel
print("variable")
local ts = game:GetService("TweenService")
print("variable")
local ti1 = TweenInfo.new(2,Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false)
print("variable")
local ti2 = TweenInfo.new(1,Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false)
print("variable")
local sound = game.Players.LocalPlayer.PlayerGui.MainMenu.poo.SoundPlayer.Main
print("variable")
local image = Player.PlayerGui.Collected.Winner
print("variable")
local currentrotation = image.ImageLabel.Rotation
print("variable")
local plr = game.Players.LocalPlayer
print("variable")

local db = false
print("variable")

local Part = script.Parent
print("variable")
print("variable")

local debounce = true
print("variable")
local Player = game.Players.LocalPlayer
local ab = false

localpart1.Touched:Connect(function()
	if not ab then
    ab = true
	repi.DD:WaitForChild("0"):FireServer()
	print("Starting Minigame")
			print("Addressed player"..Player.Name)

	Player.Character:MoveTo(workspace.teleport.PrimaryPart.Position)
	game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
	local c = workspace.Minigames["Skater Banana Cat"].Board
	c.Parent = workspace
	c.PrimaryPart = c.SkateboardPlatform
	local char = Player.Character
	local position = workspace.teleport.PrimaryPart.CFrame
	local clone = game:GetService("ReplicatedStorage").AssistantSkate:Clone()
	clone.Parent = workspace.CurrentCamera
	wait(1)
	local items = workspace.Minigames["Skater Banana Cat"]:GetChildren()
	local item = items[math.random(1, #items)]
	item.Parent = workspace
	item:PivotTo(position)
	local text = {"You will race around the map in a time limit. Follow the checkpoints."}
	textmaker:TweenPosition(UDim2.new(0.225, 0,0.4, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1)
	for i,v in ipairs(text) do
		for i = 0, string.len(v) do
			wait(0.025)
			script.poo:Play()
			textmaker.Text = string.sub(v, 1, i)
		end
		wait(string.len(v) / 25)
	end
	repi.DD:WaitForChild("50"):FireServer()
	local clone1 = game:GetService('ReplicatedStorage'):WaitForChild("Check"):WaitForChild("Checkpoint(1)"):Clone()
		clone1.Parent = workspace.CurrentCamera
		repi.Cat.Timer:FireServer()
		ab = false
	end
end)
	
local rep = game:GetService("ReplicatedStorage")

workspace.CurrentCamera:WaitForChild("Checkpoint(1)"):WaitForChild("Touch").Touched:Connect(function(touched)
	if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
			-- do something here
	workspace.CurrentCamera:WaitForChild("Checkpoint(1)"):Destroy()
	script.Sound:Play()
		local aaa =	rep.Check["Checkpoint(2)"]:Clone()
		aaa.Parent = workspace.CurrentCamera
		end
end)

workspace.CurrentCamera:WaitForChild("Checkpoint(2)"):WaitForChild("Touch").Touched:Connect(function(touched)
	if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
	workspace.CurrentCamera:WaitForChild("Checkpoint(2)"):Destroy()
	script.Sound:Play()
		local aaa =	rep.Check["Checkpoint(3)"]:Clone()
		aaa.Parent = workspace.CurrentCamera
		end
end)

workspace.CurrentCamera:WaitForChild("Checkpoint(3)"):WaitForChild("Touch").Touched:Connect(function(touched)
	if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
	workspace.CurrentCamera:WaitForChild("Checkpoint(3)"):Destroy()
	script.Sound:Play()
		local aaa =	rep.Check["Checkpoint(4)"]:Clone()
		aaa.Parent = workspace.CurrentCamera
end
end)
workspace.CurrentCamera:WaitForChild("Checkpoint(4)"):WaitForChild("Touch").Touched:Connect(function(touched)
	if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
	workspace.CurrentCamera:WaitForChild("Checkpoint(4)"):Destroy()
	script.Sound:Play()
		local aaa =	rep.Check["Checkpoint(5)"]:Clone()
		aaa.Parent = workspace.CurrentCamera
		end
end)
workspace.CurrentCamera:WaitForChild("Checkpoint(5)"):WaitForChild("Touch").Touched:Connect(function(touched)
	if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
	workspace.CurrentCamera:WaitForChild("Checkpoint(5)"):Destroy()
	script.Sound:Play()
		local aaa =	rep.Check["Checkpoint(Finish)"]:Clone()
		aaa.Parent = workspace.CurrentCamera
	end
end)
workspace.CurrentCamera:WaitForChild("Finish"):WaitForChild("Touch").Touched:Connect(function(touched)
	if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
		completedminigame = true
		Player.Character:WaitForChild("Board"):Destroy()
		print("Found humanoid")
		workspace.CurrentCamera:WaitForChild("Finish"):Destroy()
		print("Destroyed")
		script.Sound:Play()
		print("Sound")
		for i,v in ipairs(workspace.CurrentCamera:GetChildren()) do
			print("Ipairs")
			if v.Name == "Skateboard" then
				print("Yeah no")
				print("no")
			else
				print("destroy")
				v:Destroy()
			end
		end
		print("variable")
			print("no ooooooo aaaaa")
		debounce = false
		print("event")
		print("event")
		debounce = true
		print("event")
		if db == false and plr:WaitForChild("Bananacats"):WaitForChild("SkaterBananaCat").Value == false then
			print("event")
			rep.Cat.Skatefr:FireServer()
			print("event")
			db = true
			print("event")
		local din = cat.Information
		local catname = din.NName.Value
		local catimage = din.Image.Texture
		local catdiff = din.Difficulty.Value
		local catdiffcol = din.DifficultyColor.Value
		image.ImageLabel.Image = catimage
		image.ImageLabel.diff.Text = catdiff
		image.ImageLabel.diff.TextColor3 = catdiffcol
		image.ImageLabel.TextLabel.Text = "You got: "..catname
		ts:Create(sound, ti1, {Volume = 0.3}):Play()
		wait()
		image:TweenPosition(UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad)
		wait()
		script.yoo:Play()
			wait()
			Player.Character:WaitForChild("Humanoid").Health = 0
            wait(3)
				ts:Create(sound, ti1, {Volume = 1}):Play()
				image:TweenPosition(UDim2.new(0,0,-1,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad)
				db = false
			end
    end
end)

Please help

1 Like

the problem is at script.

It gets called from localscript

the problem is its creating like 120 timers so it’s gonna run out of time really fast

how did i make 120 timers?

I don’t understand

1 Like