player:LoadCharacter() causes remoteEvent to not work?

I’m just calling player:LoadCharacter() on the server, and a player has a gui called status that shows the status of the game, there is a localscript inside this status that ONLY changes the text of a textLabel when it receives the event to update the status but somehow it breaks? Doesn;'t reiceive the event at all

local ReplicatedStorage = game:GetService("ReplicatedStorage")

ReplicatedStorage.Events.RemoteEvents.UpdateStatus.OnClientEvent:Connect(function(displayText)
	print(`Received event, text: "{displayText}"`)
	script.Parent.Text = tostring(displayText)
end)

Hello fellow gremlin, could you show the script that fired the event? Maybe the event wasn’t fired at all

local function setupPlayers()
	for _, player in Players:GetPlayers() do
		player:LoadCharacter()

		local character = player.Character
		if not character then
			return
		end

		local primaryPart = character.PrimaryPart
		if not primaryPart then
			return
		end

		local humanoid = character:FindFirstChild("Humanoid", true)
		if not humanoid then
			return
		end

		table.insert(playersInGame, player)

		humanoid.Died:Once(function()
			table.remove(playersInGame, table.find(playersInGame, player))

			if #playersInGame == 0 then
				updateStatusRemoteEvent:FireAllClients("Everyone died! Restarting game...")

				task.delay(3, initialize)

				return
			end
		end)

		local spawns = map.Spawns:GetChildren()
		local randomSpawn = spawns[math.random(1, #spawns)]

		primaryPart.CFrame = randomSpawn.CFrame * CFrame.new(0, 5, 0) -- Prevent the player from spawning inside the floor
	end
end

local function startGame()
	setupPlayers()
	
	for stageNumber, stageData in STAGE_DATA do
		updateStatusRemoteEvent:FireAllClients(`Game ongoing, stage: {stageNumber}`)
		
		print("Fired")
	end
end

Did the print(“Fired”) ever fire?

1 Like

Yes, I think its a problem with the player:LoadCharacter() line because when I remove it it works normally

Wait a minute! How are you calling the function SetUpPlayers inside itself??? Edit: NVM I read it wrong.

1 Like

Here is an idea: do this instead:
local PlayerCharacter = Player.Character or Player:LoadCharacter()

1 Like

If the print fired then the event fired.

1 Like

think I found out why

im just going to put it in starterPlayerScripts and have to access the gui from there

1 Like

Maybe you should wait for each player character to load before sending the events OR wait only for the last player character to load because by then the rest would have already loaded.

1 Like

omg I just figured out I can disable the ResetOnSpawn property of my gui :person_facepalming: :person_facepalming: :person_facepalming: :person_facepalming: :person_facepalming:

1 Like

1 Like

bro was itching to use this image :sob:

1 Like