Remote not firing on respawn

I am writing a function which updates a button for the player on there death

The only time the remote fires is when the player joins, after that, everything else in the script works except the firing of the remote.

local Players = game.Players
local PlayerButtonStatusUpdate = game.ReplicatedStorage.PlayerButtonStatusRemote

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		PlayerButtonStatusUpdate:FireClient(player, "")
	end)
end)

3 Likes

Where is the location of your local script on the client? Do you mind sharing a screenshot?

1 Like

Try Humanoid.Died instead of Player.CharacterAdded

image

1 Like

So if players spawn/re-spawn
it fire from a local script?
to a script that print

No, it runs from the server script located in the photo. From there is where its supposed to fire to the clients and where it prints.

Can you show us your client-side code?

If I create the following in StarterPlayerScripts

local PlayerButtonStatusUpdate = game.ReplicatedStorage.PlayerButtonStatusRemote

PlayerButtonStatusUpdate.OnClientEvent:Connect(function(message)
	print("Message received")
end)

I get Message received when the player respawns

PlayerButtonStatusRemote.OnClientEvent:Connect(function(text)
	print("recived text")
	QueButton.Text = text
	
end)

Where is this script located?

Is it in StarterPlayerScripts?

Starter gui, its the one called PlayerQue

maybe try adding a little wait if that helps, other than that idk.

try this

local Players = game.Players
local PlayerButtonStatusUpdate = game.ReplicatedStorage.PlayerButtonStatusRemote

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		PlayerButtonStatusUpdate:FireClient(game.Players:GetPlayerFromCharacter(char), "")
	end)
end)

its probably the same thing but its worth a shot

Instead what i found easier since the gui’s are funky when recieved by the client you could just set it on the server sometimes it may not be reliable beacuse of the Clients Internet

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local FireRemote = ReplicatedStorage.__RemoteName

local Message = "Died :("

game.Players.PlayerAdded:Connect(function(player)
	local Character = player.Character or player.CharacterAdded:Wait()
	
	Character.Humanoid.Died:Connect(function()
		player.PlayerGui.ScreenGui.TextLabel.Text = Message
		
	end)
end)

My mistake realised it broke afte dieing once simple fix

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local FireRemote = ReplicatedStorage.__RemotePath



game.Players.PlayerAdded:Connect(function(player)
	
	player.CharacterAdded:Connect(function(character)
	player.Character.Humanoid.Died:Connect(function()
		player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").TextLabel.Text = MessageList[math.random(1,#MessageList)]
		end)
	end)
end)

Assuming that your ScreenGui has its property ResetOnSpawn set to true(which it will by default), the code will rerun every time the player respawns. There is no need for binding any events or using remote events.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.