|
| 25 Oct 2014 12:52 AM |
Problem: im trying to make it to were a TextLabel's text is a leaderstat of a added player and this is my script
function Add(Plr) wait(1.5) if script.Parent.Text=="" then script.Parent.Text=Plr.leaderstats.Cash.Value end end
game.Players.PlayerAdded:connect(Add)
Error: The TextLabels text is "Lable" and i can figure out the problem |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 25 Oct 2014 12:56 AM |
function Add(Plr) print(Plr, script.Parent.Text) wait(1.5) if script.Parent.Text=="" then print("2") script.Parent.Text=Plr.leaderstats.Cash.Value end end
game.Players.PlayerAdded:connect(Add)
Run that, paste the output, then I'll try to help you. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 25 Oct 2014 12:58 AM |
You're saying if the script's parent's text is nil then make it the player's stat's value. The value is an Int, you cannot concatenate a string with a number
Fix;
game.Players.PlayerAdded:connect(function(plr) wait(1.5) if script.Parent.Text == "" then script.Parent.Text = tostring(plr.leaderstats.Cash.Value) end end) |
|
|
| Report Abuse |
|
|
|
| 25 Oct 2014 12:59 AM |
| in the output the text was "Player Label" there was no error in the script |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 25 Oct 2014 01:03 AM |
Okay, easy fix.
if script.Parent.Text=="" then --see the problem? The text is equal to label, not an empty string. Set the text in the GUI to be nothing or change the condition there to script.Parent.Text=="Label"
-An empty string is not nil. -Lua let's you set strings equal to numbers generally (even though the instance is ROBLOX's, it carried over). |
|
|
| Report Abuse |
|
|
|
| 25 Oct 2014 01:07 AM |
Thanks Lord idk how i missed that thanks for the help -TheUI |
|
|
| Report Abuse |
|
|
|
| 25 Oct 2014 01:10 AM |
| ok wait one more question if the leader stat was changing how would i make the text on the text label change to i think its like math.floor |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 25 Oct 2014 01:27 AM |
| Add the .Changed event to the Cash object and run "script.Parent.Text=Plr.leaderstats.Cash.Value" every time the event is fired. |
|
|
| Report Abuse |
|
|
|
| 25 Oct 2014 01:52 AM |
| ok i dont get what you just said plz explain a bit more |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 25 Oct 2014 02:18 AM |
game.Players.PlayerAdded:connect(function(Plr Plr:WaitForChild('leaderstats'):WaitForChild('Cash').Changed:connect(function() script.Parent.Text = Plr.leaderstats.Cash.Value end) end)
|
|
|
| Report Abuse |
|
|
|
| 25 Oct 2014 02:34 AM |
the script didnt work but i think the script should be somthing like
function Add(Plr) wait(1.5) if script.Parent.Text=="Label" then Plr.leaderstats.Cash.Changed:connect(function() script.Parent.Text=Plr.leaderstats.Cash.Value end) end end |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Oct 2014 02:13 PM |
game.Players.PlayerAdded:connect(function(Player) wait(1.5) if (script.Parent.Text == '') then script.Parent.Text = Player:WaitForChild('leaderstats'):WaitForChild('Cash').Value end end) |
|
|
| Report Abuse |
|
|
|
| 25 Oct 2014 02:16 PM |
| let me try to see if it works for what im doing |
|
|
| Report Abuse |
|
|
|
| 25 Oct 2014 02:25 PM |
| what the problem is what im trying to do i have it change the text if the leaderstats value changes |
|
|
| Report Abuse |
|
|
jr41901
|
  |
| Joined: 03 Mar 2013 |
| Total Posts: 35 |
|
| |
|
| |
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|
|
| 25 Oct 2014 05:28 PM |
| it works but when the leader stat value increases the label dosnt change which is wat i need help scripting |
|
|
| Report Abuse |
|
|
| |
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 25 Oct 2014 05:56 PM |
What you need is a Changed event;
game.Players.PlayerAdded:connect(function(plr) wait(1.5) if script.Parent.Text == "" then script.Parent.Text = tostring(plr.leaderstats.Cash.Value) end
plr.leaderstats.Cash.Changed:connect(function(change) --Changed Event script.Parent.Text = tostring(plr.leaderstats.Cash.Value) --Set the text again. end)
end)
More details about it here:
http://wiki.roblox.com/index.php?title=Changed_(Event)/value |
|
|
| Report Abuse |
|
|
| |
|