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 Gold Script

Previous Thread :: Next Thread 
flash31938 is not online. flash31938
Joined: 20 Jan 2011
Total Posts: 7
23 Dec 2012 10:24 PM
I am making a gold script for a gamepass in my friends rpg, however I need to know how to make it only give the 7500 gold once. And if there are any other errors in the script could you point them out.


wait(20)


gpid = 101204054 --Game Pass ID


GPS = Game:GetService("GamePassService")
function onPlayerEntered(char)
player = game.Players:FindFirstChild(char.Name)
print("Respawned")
if char:FindFirstChild("Head") ~= nil then
print("It's a Player!")
if GPS:PlayerHasPass(player, gpid) then
print("Has GPID")
if player.leaderstats.Gold.Value < 7500 then
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 7500
elseif player.leaderstats.Gold.Value >= 7500 then
player.leaderstats.Gold.VAlue = player.leaderstats.Gold.Value
end
else
print("No GPID")
end
end
end
game.Players.ChildAdded:connect(onPlayerEntered)

Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
23 Dec 2012 10:26 PM
Use PlayerAdded, not ChildAdded.
Also, it returns the Player, not the Character.
Report Abuse
flash31938 is not online. flash31938
Joined: 20 Jan 2011
Total Posts: 7
23 Dec 2012 10:28 PM
Also how would I make it only work once per person.
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
23 Dec 2012 10:33 PM
You made it so complicated.

wait(20)


gpid = 101204054 --Game Pass ID
gold = 7500

GPS = Game:GetService("GamePassService")
function onPlayerEntered(p)
player = game.Players:GetPlayerFromCharacter(p.Parent)
if player and GPS:PlayerHasPass(player, gpid) then
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + gold
end
end
game.Players.PlayerAdded:connect(onPlayerEntered)
Report Abuse
flash31938 is not online. flash31938
Joined: 20 Jan 2011
Total Posts: 7
23 Dec 2012 10:36 PM
Thank you and do you think you can help me with my previous post as well.
Report Abuse
noah is not online. noah
Joined: 11 Sep 2006
Total Posts: 18977
23 Dec 2012 10:39 PM
Np and sure, I'll take a look @it.
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