|
| 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
|
  |
| 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 |
|
|
|
| 23 Dec 2012 10:28 PM |
| Also how would I make it only work once per person. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
|
| 23 Dec 2012 10:39 PM |
| Np and sure, I'll take a look @it. |
|
|
| Report Abuse |
|
|