RemoteEvent only firing once?

Hello, devs! I am making a GUI that changes it when it detects the player is dead. The player is killed after a RemoteEvent is fired then the GUI detects the change and changes itself. It works but the problem I have is that this only fires once. After that, it changes nothing. Here is the script. Thank you and support is appreciated!

local player = game.Players.LocalPlayer

player.Character:WaitForChild("Humanoid")

local humanoid = player.Character.Humanoid

local lives = player.Lives

humanoid.Died:Connect(function()
	print(player)
	if player then
	    game.ReplicatedStorage.PlayerDied:FireServer(player)
		print("Fired!")
	else
		return nil
	end
end)

script.Parent.Parent.MenuGui.Frame.PlayButton.MouseButton1Click:Connect(function()
	wait(0.216)
	script.Parent.Live1.Visible = true
	script.Parent.Live2.Visible = true
	script.Parent.Live3.Visible = true
	print("Lives visible!")
end)

lives:GetPropertyChangedSignal("Value"):Connect(function()
	if lives.Value == 2 then
		script.Parent.Live3.Image = "rbxassetid://7061951219"
		print("Changed!")
	end
	if lives.Value == 1 then
		script.Parent.Live2.Image = "rbxassetid://7061951219"
		print("Changed!")
	end
	if lives.Value == 0 then
		script.Parent.Live1.Image = "rbxassetid://7061951219"
		print("Changed!")
	end
end)
1 Like

So you want to fire the remote event multiple times after the player dies?

What I mean is when the player dies, a RemoteEvent is fired. However, it only fires when a player dies one time. When the player dies again or multiple times, nothing happens with no errors.

That has to do with where the script is placed. What folder is it in?

This script is inside StarterGUI inside a GUI.

First, try changing the script to this and let me know if it works.

local player = game.Players.LocalPlayer

local character = player.Character or player.CharacterAdded:wait()

local humanoid = player.Character:WaitForChild("Humanoid")

local lives = player.Lives

humanoid.Died:Connect(function()
	print(player)
	if player then
	    game.ReplicatedStorage.PlayerDied:FireServer(player)
		print("Fired!")
	else
		return nil
	end
end)

script.Parent.Parent.MenuGui.Frame.PlayButton.MouseButton1Click:Connect(function()
	wait(0.216)
	script.Parent.Live1.Visible = true
	script.Parent.Live2.Visible = true
	script.Parent.Live3.Visible = true
	print("Lives visible!")
end)

lives:GetPropertyChangedSignal("Value"):Connect(function()
	if lives.Value == 2 then
		script.Parent.Live3.Image = "rbxassetid://7061951219"
		print("Changed!")
	end
	if lives.Value == 1 then
		script.Parent.Live2.Image = "rbxassetid://7061951219"
		print("Changed!")
	end
	if lives.Value == 0 then
		script.Parent.Live1.Image = "rbxassetid://7061951219"
		print("Changed!")
	end
end)

No, it still will only change it one time.

Make sure that this setting is ticked on for all the GUI’s
image
Or atleast for the ancestors and parent of the script

This works but now it broke some of it. It will make my GUI invisible and set the images back to normal.

Then unfortunately you’ll have to either move the location of the script to be where it doesn’t break, or add scripts to the GUI that you want invisible and set them to be invisible. There might be another way, but if there is I don’t know of it :sad:

Hmm, I can make a value inside the Play Button to detect if it has been clicked once. I’ll try to fix this and report back.

1 Like

Is the value of ‘Lives’ changed at all in the script

It is changed in a Server Script.

Does this gets fired every time the player is dead?

When I do ResetOnSpawn, yes. When it is disabled, no.

Can I know what does this do??

The script is inside a GUI. So I enabled ResetOnSpawn which resets everything in the GUI when a player respawns.

Do you have to necessarily turn it off or you can turn it on?

I turn it on cause the Humanoid gets deleted everytime a player dies. But it messes up my GUI.

Then it’s best if you Parent the script to somewhere else.

1 Like