Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Unable to update value globally?

Asked by 3 years ago

I'm trying to automatically update a nametag so each player's tag shows their corresponding values. The issue is that when it updates the value, only you can see your value change, and everyone else has, "Loading..." above them. The reason why only you can see your name change is that I was using a Local Script. I tried using a Script thinking this would solve the problem, but you can't get the local player in a Script.

UpdateText Script

local player = game.Players.LocalPlayer

local statsFolder = player:WaitForChild("Leaderstats", 100)
local rank = statsFolder:WaitForChild("Rank")

local text = script.Parent

text.Text = "Rank "..rank.Value

rank.Changed:Connect(function()
    text.Text = "Rank "..rank.Value
end)

I tried wrapping it around a game.Players.PlayerAdded Function,

game.Players.PlayerAdded:Connect(function(player)
    local statsFolder = player:WaitForChild("Leaderstats", 100)
    local rank = statsFolder:WaitForChild("Rank")

    local text = script.Parent

    text.Text = "Rank "..rank.Value

    rank.Changed:Connect(function()
        text.Text = "Rank "..rank.Value
    end)
end)

But this didn't work...

Please help!

0
Side note, I found a bug to make my view counter go up, really high and really fast... EightBlits 7 — 3y
0
You should have the players fire a RemoteEvent to the server when they want to change their name, from there you can change rank.Value to whatever they want. virushunter9 943 — 3y

1 answer

Log in to vote
0
Answered by
Speedmask 661 Moderation Voter
3 years ago
Edited 3 years ago

dude... you can get the local player. first, read this. then, try these two.

click me

localscript:

local remote = ReplicatedStorage.RemoteEvent
remote:FireServer(“whaddup”)

serverscript:

remote.OnServerEvent:Connect(function(player, message)
    print(player.Name, “says”, message)
end)

try it out and see what happens. on the receiving end of OnServerEvent, the server always gets the player as the first argument and then any other arguments that were fired.

and jeez what’s up with the views on this post

0
Thanks! I'll try this right now! Also, the views are from a glitch I discovered... :P EightBlits 7 — 3y
0
This worked! I had a couple issues with it not working, but they're now all fixed! EightBlits 7 — 3y
Ad

Answer this question