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

How to make this text label compatible with LocalPlayer?

Asked by 6 years ago

:I'm trying to make a text label that shows one of the player's statistics, but the frame will be visible to multiple people at a time, so how would I use a local script to make it show the stat of the local player? I tried using my own script and it didn't change the text at all, here's the script I used:

local lplayer = game.Players.LocalPlayer
local stats = lplayer.PlayerPackage.Stats
local puzzlepiece = stats.PuzzlePieces.Zombie -- These are for defining the statistic

while true do
    wait(0.01)
    script.Parent.Text = ('  '..puzzlepiece.Value..' out of 30  ') -- This is for changing the text
end

:I didn't get any error codes in the output window when I ran the script, but did I somehow use the Local Script incorrectly? Are there any errors in my code that I haven't noticed?

1 answer

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
6 years ago

No issues with the loop or code. That narrows it down. Is the local script in the wrong place? Scripts will not execute in ReplicatedStorage or Server Storage. The other issue could be that "lplayer.PlayerPackage.Stats.PuzzlePieces.Zombie.Value" is not updating. That would mean that the value of "Zombie" is not being changed.

0
Nope, I'm executing the "Import Packages" script from the ServerScriptService, which has worked with a lot of other scripts. The local script I'm executing from inside the text label, and the value not updating wouldn't explain why the text didn't change at all, rather than to the initial value of "Zombie". EnderGamer358 79 — 6y
0
The script is either disabled or in a place where scripts won't run. Try putting the script in workspace and see if it works. Local scripts don't work in ReplicatedStorage and ServerStorage. H4X0MSYT 536 — 6y
Ad

Answer this question