|
| 24 Dec 2014 03:27 PM |
I need help making a script that goes in a giver that, when touched, it takes away 'Robux' (The name of the currency) from that player who steps/touches it. I'm not a very good scripter. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 24 Dec 2014 03:29 PM |
| I'd suggest you go look at the Touched event and Getting a Player from a Character |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2014 04:07 PM |
| I want it to take away 100 from the actual money and in leaderstats |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2014 04:15 PM |
| I just don't understand it. Just please give me the script |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
|
| 24 Dec 2014 04:51 PM |
Maybe this will help, the script's parent must be the part script.Parent.Touched:connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) plr.leaderstats.(NameOfCurrencyHere).Value = plr.leaderstats.(NameOfCurrencyHere).Value - (how much you want to subtract) end end) |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2014 05:20 PM |
It all worked except the (how much you want to subtract) part, instead of subtracting that I have no idea what it did. Here's my script:
script.Parent.Touched:connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) plr.leaderstats.Robux.Value = plr.leaderstats.Robux.Value - 100 end end)
The starting value is 100. When I touched it it made the value -400 |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2014 06:07 PM |
It must be because mulitple parts touched it at once, I'll change the script a bit :
local cooldown = false
script.Parent.Touched:connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum and cooldown == false then cooldown = true local plr = game.Players:GetPlayerFromCharacter(hit.Parent) plr.leaderstats.Robux.Value = plr.leaderstats.Robux.Value - 100 wait(thewaitamount) cooldown = false end end) |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2015 03:47 PM |
Thanks but could you possibly modify it so that if they don't have the amount of money that they need, it doesn't give it to them (I haven't tested it but looking at the script I believe if they don't have 100, it'll just make their money value negative but still give them the hat) |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2015 03:53 PM |
Try this:
local Debounce = false
script.Parent.Touched:connect(function(hit) if Debounce = false then Debounce = true local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player then local LeaderStats = Player:WaitForChild("leaderstats") local ROBUX = LeaderStats:WaitForChild("Robux") if ROBUX.Value >= 100 then ROBUX.Value = ROBUX.Value - 100 --Give hat wait(2) Debounce = false end end end end)
|
|
|
| Report Abuse |
|
|