generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Game Design
Home Search
 

Re: Button That Gives player Cash.

Previous Thread :: Next Thread 
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
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
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
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
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
02 Feb 2015 01:57 PM
Bump
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
02 Feb 2015 02:04 PM
Maybe you'll get help if you post a script you made.
Report Abuse
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
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
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
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
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
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
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
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
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
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
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
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
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
03 Feb 2015 04:03 PM
bump, Sorry for double bumping!
Report Abuse
Provisione is not online. Provisione
Joined: 01 Mar 2013
Total Posts: 51
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
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
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
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
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
freerobux456 is not online. freerobux456
Joined: 25 Feb 2010
Total Posts: 244
03 Feb 2015 07:54 PM
ew a free model?

why not just use Os Time?
Report Abuse
freerobux456 is not online. freerobux456
Joined: 25 Feb 2010
Total Posts: 244
03 Feb 2015 07:55 PM
ew, a free model?

why not just use the internal clock such as os time?
Report Abuse
freerobux456 is not online. freerobux456
Joined: 25 Feb 2010
Total Posts: 244
03 Feb 2015 07:56 PM
sry fur duble p0st
Report Abuse
DerpyMerpKing is not online. DerpyMerpKing
Joined: 05 Feb 2011
Total Posts: 2553
03 Feb 2015 08:17 PM
how many parents does the script have until it gets to StarterGui?
Report Abuse
DerpyMerpKing is not online. DerpyMerpKing
Joined: 05 Feb 2011
Total Posts: 2553
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
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
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
DerpyMerpKing is not online. DerpyMerpKing
Joined: 05 Feb 2011
Total Posts: 2553
05 Feb 2015 05:51 PM
ewwwww cheap town rp
Report Abuse
rockinnoobs is not online. rockinnoobs
Joined: 05 Sep 2012
Total Posts: 72
06 Feb 2015 05:38 PM
ewww 10 year old judging a book by its covered
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image