|
| 01 Feb 2015 08:57 PM |
I am trying to make a gui button that will give a player money when clicked. This is the code I have:
Cash Stat Script:
game.Players.PlayerAdded:connect(function(player) stat = Instance.new("IntValue") stat.Name = "leaderstats" stat.Parent = player cash = Instance.new("IntValue") cash.Name = "Cash" cash.Parent = stat end)
Give player money button:
moneyToGive = 5 debounce = false function onClicked(playerWhoClicked) if debounce == true then return end player = game.Players:GetPlayerFromCharacter(hit.Parent) if player == nil then return end stat = player:findFirstChild("leaderstats") if stat == nil then return end cash = stat:findFirstChild("Cash") if cash == nil then return end debounce = true cash.Value = cash.Value + moneyToGive wait(300) debounce = false
end
It also doesn't show the loading so that the player has to wait before getting money:
local Gui = game.Lighting.GUI --Replace this with the location of your GUI
function GiveGui(Player) if Player.PlayerGui:FindFirstChild(Gui.Name)~=nil then return end Gui:Clone().Parent=Player.PlayerGui end
script.Parent.Touched:connect(function(hit)
local Player=game.Players:GetPlayerFromCharacter(hit.Parent) if Player==nil then return end GiveGui(Player)
end) |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2015 09:54 AM |
| Come on. 12 people viewed yet no one said a thing. I would like to finish this soon. |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Feb 2015 02:04 PM |
| Maybe you'll get help if you post a script you made. |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2015 02:47 PM |
| Are you trying to say it's a bad thing? I've been editing these from the sources I found them at for hours, and no matter what I try it doesn't work. I thought the roblox community where supposed to help. I just am trying to finish this script and the best thing your doing for me is bring my post up higher. Don't comment unless your helping. |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2015 02:52 PM |
| Maybe if you tell us the directory of the button, we might be able to make one for you. |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2015 02:54 PM |
| I have it under StarterGui. Its a screen gui with a Textbutton on the side with 2 scripts. one for a job loading sequence I guess you could say, and another one that gives the play the money. These scripts work on a brick, but not on a button even though I change it to OnClick. |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2015 02:59 PM |
Put this in the button
script.Parent.MouseButton1Down:connect(function() local player = game.Players.LocalPlayer local stats = player.leaderstats local cash = stats.Cash
money = 5
cash.Value = cash.Value + money end) |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2015 03:09 PM |
| Thank you so much! Now I just have one last question, would it work if I added wait() in to that code so that the play can't spam his money? I just tried to but it just made the timing for it off by a lot. Also, this may be pushing it but that loading code I had didn't really work on the button either. If it isn't a pain could I maybe have some help with that to? |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2015 07:05 PM |
| Your script amazing! But it can be spammed and keeps giving the player money but I can't figure out how to get the wait function to work. Could you maybe add this real quick? |
|
|
| Report Abuse |
|
|
|
| 03 Feb 2015 04:03 PM |
| bump, Sorry for double bumping! |
|
|
| Report Abuse |
|
|
|
| 03 Feb 2015 05:34 PM |
I know C++, C, JavaScript, HTML, CSS, NOT LUA
But you could try and add a wait(.5) or something, maybe then it cant get spammed. |
|
|
| Report Abuse |
|
|
|
| 03 Feb 2015 05:51 PM |
| I tried that, all it does is wait 5 seconds, and still allow player stop be spammed. I want it so that the player can click it, then have to wait a minute before clicking it again. |
|
|
| Report Abuse |
|
|
|
| 03 Feb 2015 07:12 PM |
| I figured it out! I did a little bit of digging and found a free model that adds money to there cash every 5 minutes. |
|
|
| Report Abuse |
|
|
|
| 03 Feb 2015 07:54 PM |
ew a free model?
why not just use Os Time? |
|
|
| Report Abuse |
|
|
|
| 03 Feb 2015 07:55 PM |
ew, a free model?
why not just use the internal clock such as os time? |
|
|
| Report Abuse |
|
|
| |
|
|
| 03 Feb 2015 08:17 PM |
| how many parents does the script have until it gets to StarterGui? |
|
|
| Report Abuse |
|
|
|
| 03 Feb 2015 08:19 PM |
NVM
debounce = false
script.Parent.MouseButton1Down:connect(function() if debounce == false then debounce = true local player = game.Players.LocalPlayer local stats = player.leaderstats local cash = stats.Cash
money = 5
cash.Value = cash.Value + money wait(.5) debounce == false end) |
|
|
| Report Abuse |
|
|
|
| 04 Feb 2015 01:42 PM |
These post are way to late. I already released the game I was working on in the time you replied.
SELF ADVERTISMENT!
www.roblox.com/Forum/ShowPost.aspx?PostID=155318221 |
|
|
| Report Abuse |
|
|
| |
|
|
| 06 Feb 2015 05:38 PM |
| ewww 10 year old judging a book by its covered |
|
|
| Report Abuse |
|
|