Script only does the first one

Replicated = game:GetService("ReplicatedStorage")
Player = game:GetService("Players").LocalPlayer
timesFQ = 0
timeYE = 0
timeSoNaund = 0
timesSoundPlayed = 0
human = nil
Player.Chatted:Connect(function(message: string)
	local randomMusic = Replicated.Sounds:GetChildren()[math.random(1,# Replicated.Sounds:GetChildren())]
	randomMusic:Play()
	if Replicated.Sounds.YE.IsPlaying == true then
		timeYE += 1
	end
	timesSoundPlayed += 1
	
	
	if timeYE>=3 then
		Replicated.Sounds:Destroy()
		script:Destroy()
		workspace["Music Box Alive"]:Play()
		game.Lighting.ColorCorrection.Enabled = true
		task.wait(10)
		Player:Kick("Bad")
		if Replicated.Sounds.FQ.IsPlaying == true then
			timesFQ += 2
		end
		
		
		
		
		
		if timesFQ>=5 then
			Replicated.Sounds:Destroy()
			script:Destroy()
			workspace["Music Box Alive"]:Play()
			game.Lighting.ColorCorrection.Enabled = true
			task.wait(5)
			Player:Kick("Funny.")
			if timeSoNaund>=3 then
				Player:Kick()
			end
			
			
			
			
			
			if Replicated.Sounds.SoNAund:Play() then
				timeSoNaund += 1
			end
			

It only kicks “bad” the other kick won’t work as it’s just this line who works. Any ways to fix this? I know this is a bit messy

1 Like

Try putting the highest value first

Replicated = game:GetService("ReplicatedStorage")
Player = game:GetService("Players").LocalPlayer
timesFQ = 0
timeYE = 0
timeSoNaund = 0
timesSoundPlayed = 0
human = nil
Player.Chatted:Connect(function(message: string)
	local randomMusic = Replicated.Sounds:GetChildren()[math.random(1,# Replicated.Sounds:GetChildren())]
	randomMusic:Play()
	if Replicated.Sounds.YE.IsPlaying == true then
		timeYE += 1
	end
	timesSoundPlayed += 1
	
	if timesFQ>=5 then
			Replicated.Sounds:Destroy()
			script:Destroy()
			workspace["Music Box Alive"]:Play()
			game.Lighting.ColorCorrection.Enabled = true
			task.wait(5)
			Player:Kick("Funny.")
			if timeSoNaund>=3 then
				Player:Kick()
		
			
	elseif timeYE>=3 then
		Replicated.Sounds:Destroy()
		script:Destroy()
		workspace["Music Box Alive"]:Play()
		game.Lighting.ColorCorrection.Enabled = true
		task.wait(10)
		Player:Kick("Bad")
		if Replicated.Sounds.FQ.IsPlaying == true then
			timesFQ += 2
		end
		
		
		
		
		
		
			
			
			
			
			if Replicated.Sounds.SoNAund:Play() then
				timeSoNaund += 1
			end
1 Like

Nothing is happening. No kicks just sounds playing once you talk

What if you use elseif statements, instead of having separate blocks of code?

Uh what do you really mean by that

On the 1st block of code you have an if statement, but from there onwards you can use elseif statements instead, thus linking them all together.

Like what @Floyddo has done:

This might be why the game may only be running on the 1st block.

2 Likes

I’m about to said that. Mark this as Solution!

Huh? What do you mean , Comment what ???

1 Like

It really changed nothing , just sounds playing. The player doesn’t get kicked

Do you get any errors in the script?

No I remember there is no errors

Which script did you update and it didn’t work?

Oh my bad I made another topic and I thought it was this one , and no yep there is no errors

If these are your variables, you need to put ‘local’ before them, like this:

local Replicated = game:GetService("ReplicatedStorage")
local Player = game:GetService("Players").LocalPlayer
local timesFQ = 0
local timeYE = 0
local timeSoNaund = 0
local timesSoundPlayed = 0
local human = nil

I have impoved the format slightly:

local Replicated = game:GetService("ReplicatedStorage")
local Player = game:GetService("Players").LocalPlayer
local timesFQ = 0
local timeYE = 0
local timeSoNaund = 0
local timesSoundPlayed = 0
local human = nil

Player.Chatted:Connect(function(message: string)
	local randomMusic = Replicated.Sounds:GetChildren()[math.random(1,# Replicated.Sounds:GetChildren())]
	randomMusic:Play()
	end)
	
	if Replicated.Sounds.YE.IsPlaying == true then
	timeYE += 1
else
	timesSoundPlayed += 1
end


if timesFQ>=5 then
	Replicated.Sounds:Destroy()
	script:Destroy()
	workspace["Music Box Alive"]:Play()
	game.Lighting.ColorCorrection.Enabled = true
	task.wait(5)
	Player:Kick("Funny.")
	if timeSoNaund>=3 then
		Player:Kick()
	elseif timeYE>=3 then
		Replicated.Sounds:Destroy()
		script:Destroy()
		game.Workspace["Music Box Alive"]:Play()
		game.Lighting.ColorCorrection.Enabled = true
		task.wait(10)
		Player:Kick("Bad")
	end

	if Replicated.Sounds.FQ.IsPlaying == true then
		timesFQ += 2
	end

	if Replicated.Sounds.SoNAund:Play() then
		timeSoNaund += 1
	end
end