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 » Scripting Helpers
Home Search
 

Re: button that adds value to int?

Previous Thread :: Next Thread 
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
01 Dec 2013 07:24 PM
x = script.Parent

function mouseclick(click)
local c = click.Parent:FindFirstChild('Humanoid')
if c then
gems = c.Parent:FindFirstChild('Gems')
gems = Gems.Value + 1
end
end

x.MouseButton1Click:connect(click)

I want it so that when the gui button is pressed, you gain 1 gem.
Report Abuse
BetterBe is not online. BetterBe
Joined: 25 Jan 2009
Total Posts: 1034
01 Dec 2013 07:27 PM
plr = game.Players.LocalPlayer
plrCharacter = plr.Character

x = script.Parent

function mouseclick(click)
local c = plrCharacter:FindFirstChild('Humanoid')
if c then
gems = plrCharacter:FindFirstChild('Gems')
gems = Gems.Value + 1
else
end
end

x.MouseButton1Click:connect(click)


--use this in a localscript in the button (same result, only fixed)
--also assuming there is 'Gems' inside the player.
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
01 Dec 2013 07:28 PM
x = script.Parent

function mouseclick(click)
local c = click.Parent:FindFirstChild('Humanoid')
if c then
gems = c.Parent:FindFirstChild('Gems')
gems = Gems.Value + 1
end
end

x.MouseButton1Click:connect(mouseclick)

I want it so that when the gui button is pressed, you gain 1 gem.
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
01 Dec 2013 07:37 PM
Still won't work. Here is the leaderboard.

game.Players.PlayerAdded:connect(function(plr)
local w = Instance.new('IntValue', plr)
w.Name = 'leaderstats'
local x = Instance.new('IntValue', w)
x.Name = 'Gems'
x.Value = 0
local y = Instance.new('IntValue', w)
y.Name = 'Cash'
y.Value = 0
while true do
wait(10)
y.Value = y.Value + 5
end
end)

And the gui is structured like this:

StarterGui
>ScreenGui
>>TextButton(gemclicker)
>>>Localscipt(addgems)

Inside the script:

plr = game.Players.LocalPlayer
plrCharacter = plr.Character

x = script.Parent

function mouseclick(click)
local c = plrCharacter:FindFirstChild('Humanoid')
if c then
gems = plrCharacter:FindFirstChild('Gems')
gems = Gems.Value + 1
else
end
end

x.MouseButton1Click:connect(click)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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