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

LocalScript doesn't work at all, Please help?

Asked by 8 years ago

I've tried everything I can to make this LocalScript work, but it doesn't. Nothing shows up in the output.

local plr = game.Players.LocalPlayer
local amofcash = plr.leaderstats:WaitForChild('Cash').Value

script.Parent.Text = '$ '..plr.leaderstats:WaitForChild('Cash').Value
amofcash.Changed:connect(function()
script.Parent.Text = '$ '..plr.leaderstats:WaitForChild('Cash').Value
end)
1
Please use your variubles. You have created them for a reason, right? SH_Helper 61 — 8y
0
Please you don't know anything. Stop TheEpicCooldeal 12 — 8y

2 answers

Log in to vote
0
Answered by
P100D 590 Moderation Voter
8 years ago

The changed event should be referencing the value object, not its value property. In other words, it should be Cash.Changed and not Cash.Value.Changed

Also, use variables if you've initialized them.

Basically, your script should be changed to this:

local plr = game.Players.LocalPlayer
local amofcash = plr.leaderstats:WaitForChild('Cash'

script.Parent.Text = '$ '.. amofcash.value
amofcash.Changed:connect(function()
script.Parent.Text = '$ '.. amofcash.Value
end)

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

Where is this LocalScript? It will only run if it's in the player's backpack, PlayerGui, PlayerScripts, the player's character model, or ReplicatedFirst.

0
It's parent is the TextLabel that it's text should change when a player's cash is changed. Problem is it's always on $0 which is the default TheEpicCooldeal 12 — 8y
1
Oh, gotcha. You didn't explain your issue very well so I assumed it was an issue with the script's code executing at all. Your issue with updating the values stems from how you fired the .Changed event. A value object's .Value property won't return the change needed for the event to fire, so changing the event to be fired when the Cash object of leaderstats is changed should fix your problem. DepressionSensei 315 — 8y
0
In other words, plr.leaderstats.Changed:connect(function() --your code here end) DepressionSensei 315 — 8y

Answer this question