generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Script Help

Previous Thread :: Next Thread 
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
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 is not online. 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 is not online. 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
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
25 Oct 2014 12:59 AM
in the output the text was "Player Label" there was no error in the script
Report Abuse
lordrambo is not online. 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
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
25 Oct 2014 01:07 AM
Thanks Lord idk how i missed that thanks for the help
-TheUI
Report Abuse
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
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 is not online. 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
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
25 Oct 2014 01:52 AM
ok i dont get what you just said plz explain a bit more
Report Abuse
Casualist is not online. 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
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
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
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
25 Oct 2014 02:10 PM
Bump for help
Report Abuse
FameAssistant is not online. FameAssistant
Joined: 14 Jan 2012
Total Posts: 14
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
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
25 Oct 2014 02:16 PM
let me try to see if it works for what im doing
Report Abuse
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
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 is not online. jr41901
Joined: 03 Mar 2013
Total Posts: 35
25 Oct 2014 04:38 PM
BUMP FO A FRIEND >:DDDDd
Report Abuse
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
25 Oct 2014 04:43 PM
Bump halp!
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
25 Oct 2014 05:18 PM
Try mine?
Report Abuse
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
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
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
25 Oct 2014 05:34 PM
Buttz bump lol
Report Abuse
Goulstem is not online. 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
TheUIMaker is not online. TheUIMaker
Joined: 18 Oct 2014
Total Posts: 32
25 Oct 2014 06:19 PM
Omjezels thx
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image