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 » Scripters
Home Search
 

Re: Updating a value.

Previous Thread :: Next Thread 
F3XStudios is not online. F3XStudios
Joined: 08 Nov 2015
Total Posts: 94
13 Feb 2016 02:06 PM
Okay so have a script that creates a folder for the players stat's inside the player here's the script if you dont know what I mean

game.Players.PlayerAdded:connect(function(plr)

local Folder = Instance.new("Folder",plr)
Folder.Name = "Stats"
local Cash = Instance.new("IntValue",Folder)
Cash.Name = "Cash"
Cash.Value = 25
local VIP = Instance.new("BoolValue",Folder)
VIP.Name = "VIP"

end)

but I am trying to this this properly so basicly when the cash value changes I want the value to update as well. I have this script below in a local script inside the player gui but it does not work suggestions?

game.Players.Player.Stats.Cash.Value.Changed:connect(function()
script.Parent.Parent.Players.Player.PlayerGui.ScreenGui.Cash.Button.Text = script.Parent.Parent.Players.Player.Stats.Cash.Value
end)
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
13 Feb 2016 02:09 PM
game.Players.Player.Stats.Cash.Value.Changed:connect(function()
script.Parent.Parent.Players.Player.PlayerGui.ScreenGui.Cash.Button.Text = script.Parent.Parent.Players.Player.Stats.Cash.Value
end)
should be

game.Players.LocalPlayer.Stats.Cash.Value.Changed:connect(function()
game.Players.LocalPlayer.PlayerGui.ScreenGui.Cash.Button.Text = game.Players.LocalPlayer.Stats.Cash.Value
end)
Report Abuse
F3XStudios is not online. F3XStudios
Joined: 08 Nov 2015
Total Posts: 94
13 Feb 2016 02:12 PM
I got an error

12:11:42.775 - Players.Player.PlayerGui.LocalScript:2: attempt to index field 'Value' (a number value)
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
13 Feb 2016 02:14 PM
Well, what is this "Stats" thing anyway?
Report Abuse
F3XStudios is not online. F3XStudios
Joined: 08 Nov 2015
Total Posts: 94
13 Feb 2016 02:16 PM
It's a folder inside the player It's for me to keep track of important thing's such as value's and it would make it 100X times easier for data saving.
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
13 Feb 2016 02:18 PM
My mistake, here's the working version -- I hope.

game.Players.LocalPlayer.Stats.Cash.Changed:connect(function()
game.Players.LocalPlayer.PlayerGui.ScreenGui.Cash.Button.Text = game.Players.LocalPlayer.Stats.Cash.Value
end)
Report Abuse
F3XStudios is not online. F3XStudios
Joined: 08 Nov 2015
Total Posts: 94
13 Feb 2016 02:20 PM
Thank you sir, I just seem to have a hard time getting values out side of a service it's just weird for me lol have a nice day ty.
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
13 Feb 2016 02:42 PM
You're welcome.
Here's a tip.
If you're setting a value into a variable, it won't update or detect a change unless updated.

Such as:

game.Players.LocalPlayer.Charcter.Humanoid.Health.Changed -- won't work, because health is a value.

game.Player.LocalPlayer.Character.Humanoid.Changed:connect(function()
if game.Player.LocalPlayer.Character.Humanoid.Health < = 90 then
-- blah
end
end)

That would work.
Report Abuse
AdvancedObjects is not online. AdvancedObjects
Joined: 11 Dec 2012
Total Posts: 3354
13 Feb 2016 02:43 PM
http://wiki.roblox.com/index.php?title=Variable



Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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