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

Other player not seeing my overhead number?

local PlayerAdded = game.Players.PlayerAdded
local player = game.Players.LocalPlayer
local frame = script.Parent.Parent
local Lvl = script.Parent


while wait(1) do
	Lvl.Text = player:FindFirstChild("Extra"):WaitForChild("Data_Level").Value

end

for both players it says Loading.. does not change? this is in a serverscript

1 comment

0

If this is a local script how come you can use .LocalScript

2 answers

✓ Accepted answer

Since you are changing the parent's text on the client, the change will not replicate to the server. This means that only that player will see the changes. This also means that the change didn't technically occur because it is never changed on the server.

To fix this, use a PlayerAdded event to edit the text when a new player joins. This event has a player parameter that refers to the player that joined. Also pair this with a GetPropertyChangedSignal event that will fire whenever the value changes rather than every second inside a while loop.

game:GetService("Players").PlayerAdded:Connect(function(player)
	local levelData = player.Extra:WaitForChild("Data_Level")
	local Lvl --Set this to the path of the Gui

	levelData:GetPropertyChangedSignal("Value"):Connect(function()
		Lvl.Text = levelData.Value
	end)

	Lvl.Text = levelData.Value --Set it outside the event so it updates when they first join
end)

Hope this helped!

2 comments

0

eveeyones rank changes? how do i fix that

0

You would need to make this a script inside the player's Gui depending on what type of Gui it is. From there, check if that specific player's stats changed and only update their Gui.

first of all, player = game.Players.LocalPlayer is for a local script. Ok now you need to define a player for a server script which can be access with

game.Players.PlayerAdded:Connect(function(player)
	--Code here
end)

now you have define what player is, next is looping

while wait(1) do
    Lvl.Text = player:FindFirstChild("Extra"):WaitForChild("Data_Level").Value
end

Let me know if it helps

1 comment

0

works fine!

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