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

TextLabel Leaderstats connection not working, why? HELP!

Asked by
BryanFehr 133
4 years ago
Edited 4 years ago

Hello all!

I've been working on a new Club Game for ROBLOX, and I have been running into some trouble in regards to having the in-game currency, (VCash), show up inside of a text label! I will be providing gyazo images below to better understand my problems with the error code given by ROBLOX Studio!

Essentially, what I want to do is create a GUI that will tell the player their VCash amount inside the GUI where you purchase VCash. I have created the GUI, done the other coding for the GUI(The DeveloperProduct purchase calls, and handler), but I can't seem to figure out this simple trick in ROBLOX.

This has worked for me in previous games, but doesn't seem to now. I realize it may be out dated, but I'd like to know how to fix this problem asap!

Any and all help would be appreciated! Here are my images:

The Error Code(And Int Value in the player) -- https://gyazo.com/66f776536882d57c79691def71a50819

The Shop/Where the Label is -- https://gyazo.com/b06753a8fd43b51d596a971e3a5124d0

The Code itself that's failing:

wait();
while wait(0.1) do
    script.Parent.Text = "V-Cash: "..game.Players.LocalPlayer.leaderstats.VCash.Value;
end;

2 answers

Log in to vote
1
Answered by
Thetacah 712 Moderation Voter
4 years ago

Hi!

VCash may not have loaded into leaderstats yet, so that may be why you're encountering this error.

Try adding an if statement:

wait();
while wait(0.1) do
    local leaderstats = game.Players.LocalPlayer:FindFirstChild("leaderstats"):FindFirstChild("VCash")
    if leaderstats then
            script.Parent.Text = "V-Cash: "..game.Players.LocalPlayer.leaderstats.VCash.Value;
    end
end;

Cheers.

Ad
Log in to vote
-1
Answered by 4 years ago

instead of script.parent, try

game.PlayerGui.TextLabel.Text = ""V-Cash: "..game.Players.LocalPlayer.leaderstats.VCash.Value;"

because sometimes it wont update

Answer this question