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: Help with a script.

Previous Thread :: Next Thread 
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
20 Jul 2012 09:29 AM
Two scripts.

Script 1:


game.Players.PlayerAdded:connect(function(player)
print ("Player joined the game!")
player:WaitForDataReady()
c = player:LoadNumber("Money")
b = player:LoadBoolean("Played")
if c.Value == 0 and b.Value == false then
print ("Player needs a new money value!")
player.CharacterAdded:connect(function(character)
a = Instance.new("NumberValue")
a.Parent = character
a.Name = ("Money")
a.Value = 100
a:SaveNumber("Money")
a:SaveBoolean("Played", true)
print("New money value was created!")
end)
end
end)



Script 2:

gui = script.Parent
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
player:WaitForDataReady()
cash = character.Money.Value
cash:Changed(Value)
gui.Text = (cash.."$")
end)
end)



They both don't have a output and don't work in online or solo. Help?
Report Abuse
Zomebody is not online. Zomebody
Joined: 01 Jun 2010
Total Posts: 789
20 Jul 2012 09:33 AM
I don't believe you've put script 2 in the workspace. Scripts that aren't in the workspace or Players won't work. (As far as I know)
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
20 Jul 2012 10:08 AM
script 2 is inside of a gui.
Report Abuse
applechicken101 is not online. applechicken101
Joined: 22 Oct 2011
Total Posts: 4602
20 Jul 2012 10:22 AM
is te gui in the wrokspace?
Report Abuse
Zomebody is not online. Zomebody
Joined: 01 Jun 2010
Total Posts: 789
20 Jul 2012 10:23 AM
Then it sure won't work. If a Player enters, the Player loads first, and then the tools and Gui's are placed inside of it. If you make a "PlayerAdded" script, and put it in the Gui, it will only trigger when someone else joins the game, because once the Gui is put inside of the Player, the player has already entered.
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
20 Jul 2012 10:25 AM
So do I need to add a wait() or something?
Report Abuse
Zomebody is not online. Zomebody
Joined: 01 Jun 2010
Total Posts: 789
20 Jul 2012 10:28 AM
No, you need to put it in the workspace.
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
20 Jul 2012 10:38 AM
game.Players.PlayerAdded:connect(function(player)
wait(0.5)
player.CharacterAdded:connect(function(character)
gui = player.PlayerGui.Money.Frame.TextLabel
player:WaitForDataReady()
cash = character.Money.Value
cash:Changed(Value)
gui.Text = (cash.."$")
end)
end)


Thats the new script. It still doesn't work. Do remember that script 2 will not work unless script 1 works.
Report Abuse
Zomebody is not online. Zomebody
Joined: 01 Jun 2010
Total Posts: 789
20 Jul 2012 10:44 AM
cash = character.Money.Value
cash:Changed(Value)

Changed is an event from a Value. Not from a Value's Value. So it's supposed to be:

cash = character.Money.Value
character.Money:Changed(Value)
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
20 Jul 2012 10:50 AM
Still doesn't work.

And a question:

Does changed work only once? Or does it activate EVERY time the value changes?
If so, that can't work.
Report Abuse
Zomebody is not online. Zomebody
Joined: 01 Jun 2010
Total Posts: 789
20 Jul 2012 10:54 AM
I've never used it, but I think it's supposed to be for multiple uses. Right now I'm quite busy so I probably won't react anymore for some time.
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
20 Jul 2012 10:55 AM
If for multiple uses, then it should be okay. Loops will just be plain laggy.
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
20 Jul 2012 11:38 AM
bump
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
20 Jul 2012 01:11 PM
This is still broken. Just saying.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
20 Jul 2012 02:20 PM
First of all, SaveNumber has two arguments.

a:SaveNumber("Money", 0)

Second, Changed is an event, and it runs in an object, not a property.

gui = script.Parent
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
player:WaitForDataReady()
cash = character.Money
cash.Changed:connect(function(Value)
gui.Text = (cash.Value.."$")
end)
end)
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
20 Jul 2012 02:50 PM
Not working.
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
20 Jul 2012 02:52 PM
Can't post the output though...
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
20 Jul 2012 02:55 PM
game.Players.PlayerAdded:connect(function(player)
wait(0.5)
player.CharacterAdded:connect(function(character)
gui = player.PlayerGui.Money.Frame.TextLabel
player:WaitForDataReady()
cash = character.Money.Value
cash:Changed(Value)
gui.Text = (cash.."$")
end)
end)

idk how... but make something like: cash:connect(changed) like that
Report Abuse
liavt is not online. liavt
Joined: 12 Mar 2009
Total Posts: 1241
21 Jul 2012 08:50 AM
Still not working...

I believe its something with script 1.
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
26 Jul 2012 08:07 AM
while true do?
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