At first I made a more complex script but after numerous attempts of it not working I commited to a simpler one, and yet it doesn’t work.
This is the script.
local rs = game:GetService("ReplicatedStorage")
local plr = game.Players.LocalPlayer
plr.CharacterAdded:Connect(function(char)
local Coins = plr:WaitForChild("leaderstats").Coins
local UI = plr.PlayerGui.MenuUi
local coinstxt = UI.MenuFrame.Coins.CoinLabel
coinstxt.Text = "hi"
end)
local rs = game:GetService("ReplicatedStorage")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
if char then
local Coins = plr:WaitForChild("leaderstats").Coins
local UI = plr.PlayerGui.MenuUi
local coinstxt = UI.MenuFrame.Coins.CoinLabel
coinstxt.Text = "hi"
end
So prints also dont work directly after CharacterAdded? Could be also the cause of WaitForChild being stuck in a yield so the Text line isnt running. Also, you could try using Humanoid.Died.
For the client, your character has likely loaded before you can even connect .CharacterAdded event. This is just the case – this is why you often use CharacterAdded directly under PlayerAdded.
To fix it, you can do @zahra_y735 's suggestion by doing plr.Character or plr.CharacterAdded:Wait()
Or you can just make a separate function → call it for the first time upon player join → connect it to CharacterAdded event