|
| 19 Sep 2016 07:01 AM |
Hey guys in my game, I want to add a thing for players!! It goes like this - in an tycoon, there will be a brick. If a player steps on it,they get 50 cash(currency name = cash). If it is the owner of the tycoon who steps on it,then he won't get the cash. And if a player already collected the cash, then he can't do it again! How can you script this!!!???!!!??
Thanks! |
|
|
| Report Abuse |
|
|
Mitko0o1
|
  |
| Joined: 30 Nov 2010 |
| Total Posts: 5725 |
|
|
| 19 Sep 2016 07:31 AM |
playersWithCash = {} cash_ammount = 50 currency = "cash" -- part = script.Parent
part.Touched:connect(function(hit) local char = hit.Parent local plr = game.Players:GetPlayerFromCharacter(char) if not plr then char = hit.Parent.Parent -- this means the hit is a hat or a tool plr = game.Players:GetPlayerFromCharacter(char) end if plr then local playerCollected
for _,v in pairs(playersWithCash) do if v == plr.Name then playerCollected = true break end end
if playerCollected == nil then local leaderstats = plr:WaitForChild("leaderstats") local myCur = leaderstats:WaitForChild(currency) myCur.Value = myCur.Value + cash_ammount end end
end) |
|
|
| Report Abuse |
|
|
| |
|