|
| 16 Mar 2017 06:33 PM |
This was my original script. It had one flaw. Since it was inserted into coins dropped by npcs when killed the coins sometimes collded with the npcs instead.
amnt = 7 function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if (h~=nil) then local thisplr = game.Players:findFirstChild(h.Parent.Name) if (thisplr~=nil) then local stats = thisplr:findFirstChild("leaderstats") if (stats~=nil) then local score = stats:findFirstChild("Money") if (score~=nil) then score.Value = score.Value + amnt end end end script.Parent:remove() end end
script.Parent.Touched:connect(onTouched) ---------------------------------------------------------------------------------
Then I asked for help to make this script. Which is supposed to only give cash if it is an actual player. But now it doesn't do anything at all. Can someone edit it so it gives money but only to an actual player.
amnt = 7 --How much money deb = true --To prevent multiple touching
script.Parent.Touched:connect(function(hit)
if deb == true then deb = false local player = game.Players[hit.Parent.Name] --Should get the player (Let me know if not) local stats = game.Players.player.leaderstats.Money --From player to it's stats. stats.Value = stats.Value + amnt --Giving the player cash. script.Parent:Destroy() --Removing the egg after it gave cash. end
end)
|
|
|
| Report Abuse |
|
|
|
| 16 Mar 2017 06:41 PM |
game.Players:Get Player From Character(hit.Parent)
No space. |
|
|
| Report Abuse |
|
|
|
| 16 Mar 2017 06:51 PM |
| It says player is not a valid member of players. |
|
|
| Report Abuse |
|
|
| |
|
hasang1
|
  |
| Joined: 09 Nov 2012 |
| Total Posts: 903 |
|
|
| 16 Mar 2017 06:55 PM |
Someone forgot all about accessing instances requiring a name, not another instance.
local amnt,deb=7,true script.Parent.Touched:connect(function(hit) if deb == true then deb = false local player = game.Players:FindFirstChild'hit.Parent.Name' if not player then return end local stats=player:FindFirstChild'leaderstats' if not stats then return end local money=stats:FindFirstChild'Money' if not moneythen return end money.Value = money.Value + amnt --Giving the player cash. script.Parent:Destroy() --Removing the egg after it gave cash. end end)
HAX. |
|
|
| Report Abuse |
|
|