VitimanA
|
  |
| Joined: 04 Apr 2008 |
| Total Posts: 869 |
|
|
| 17 Aug 2011 09:51 PM |
| so i'm working on a script that when you buy a "vip" shirt for something that gives you a weapon, but it only gives you weapons 1 time only, when you enter again, it won't(like the vip shirt is avaliable for 1 time) Is there a method? |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 17 Aug 2011 09:56 PM |
So... a person buys the shirt, enters and gets the weapon then leaves and comes back and doesn't get the weapon?
Weapon = game:GetService("Lighting"):FindFirstChild("Weapons Name Here")
game:GetService("Players").PlayerAdded:connect(function(newPlayer) newPlayer:WaitForDataReady() local HasGottenGun = false pcall(function() HasGottenGun = newPlayer:LoadBoolean("HasGun") end) if not HasGottenGun then Weapon:clone().Parent = newPlayer.StarterGear pcall(function() newPlayer:SaveBoolean("HasGun", true) end) end end) |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2011 09:57 PM |
First, use .PlayerAdded. Next use .CharacterAdded. Check to make sure that the player is wearing the shirt. Clone the weapon from somewhere into the player's backpack.
(Not StarterGear, because CharacterAdded runs every time the player enters. Therefore, if you put it in StarterGear, if the player died he'd have 2 of that weapon) |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 17 Aug 2011 09:59 PM |
And facepalm, I'm doing it wrong.
Weapon = game:GetService("Lighting"):FindFirstChild("Weapons Name Here") ShirtId = 1
game:GetService("Players").PlayerAdded:connect(function(newPlayer) newPlayer:WaitForDataReady() local HasGottenGun = not game:GetService("BadgeService"):UserHasBadge(newPlayer.userId, ShirtId) pcall(function() HasGottenGun = newPlayer:LoadBoolean("HasGun") end) if not HasGottenGun then Weapon:clone().Parent = newPlayer.StarterGear pcall(function() newPlayer:SaveBoolean("HasGun", true) end) end end)
Easy fix. :3 |
|
|
| Report Abuse |
|
|