Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why are my events not being fired?

function winner()
	for _,v in pairs(game.Players:GetPlayers()) do
		v:LoadCharacter()
	end
end

while wait(1) do
	kills = workspace.LeaderBoard.Blue.Value
	script.Parent.Text = ""..kills.."/50"
end


function oops()
	print("oops")
	if kills >= 50 then
		local message = Instance.new("Message")
		message.Text = "Red Wins!"
		message.Parent = workspace
		game:GetService("Debris"):AddItem(message, 2)
		wait(1)
		winner()
		workspace.LeaderBoard.Blue.Value = 0
		workspace.LeaderBoard.Red.Value = 0
	end
end

game.ReplicatedStorage.customevent.Event:connect(oops)

I need the function "oops" to fire everytime a player dies. I tried using a remote event and a bindable event. No output errors and oops is not being printed.

This is the script that fires the event.

function died (player)
	print(player.TeamColor)
	game.ReplicatedStorage.customevent:Fire()
	if player.TeamColor == BrickColor.new("Bright red") then
		workspace.LeaderBoard.Red.Value = workspace.LeaderBoard.Red.Value + 1
		print("Red Died")
	elseif player.TeamColor == BrickColor.new("Bright blue") then
		workspace.LeaderBoard.Blue.Value = workspace.LeaderBoard.Blue.Value + 1
		print("Blue Died")
	else print("Error Error Error")
	end
end

game.ReplicatedStorage.Died.OnServerEvent:connect(died)

The script that fires that event works.

I really just need the if statement to constantly check if the value is 50. I tried using a loop but then it puts the player in a respawn loop. I tried using break to stop the loop but then the loop doesn't resume when the player respawns.

3 comments

0

What is game.ReplicatedStorage.Died?

0

A remote event that is fired everytime a player dies.

0

The only event not being fired is "game.ReplicatedStorage.customevent:Fire()"

1 answer

✓ Accepted answer

It's because at the top you have a while true do that never breaks so the script never gets off the loop. TO fix just remove the loop or add a point of break because lua reads top from bottom but with a while loop it sticks in that scope.

This discussion is preserved as it was. New answers, comments, and votes are closed.