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 » Scripters
Home Search
 

Re: Nooby Script Help

Previous Thread :: Next Thread 
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
06 Feb 2016 10:35 PM
So this script is for a shop GUI. The "God Pickaxe" costs a certain amount of "Kills" and a certain amount of "Gold". I want it so it wont take away your kills when you purchase the "God Pickaxe", but I still want it to take away the "Gold".



player = script.Parent.Parent.Parent.Parent.Parent
money = player.leaderstats.Gold
kills = player.leaderstats["Agility Tickets"]
price = 5
requiredKills = 2 -- change to amount of kills needed
tool = game.Lighting:findFirstChild("God Pickaxe")


function buy()
if (money.Value >= price) and (kills.Value >= requiredKills) then
money.Value = money.Value - price
kills.Value = kills.Value - requiredKills
local a = tool:clone()
a.Parent = player.Backpack
local b = tool:clone()
b.Parent = player.StarterGear
end
end
script.Parent.MouseButton1Down:connect(buy)
Report Abuse
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
06 Feb 2016 10:38 PM
bump..........................
Report Abuse
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
06 Feb 2016 10:40 PM
help
Report Abuse
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
06 Feb 2016 10:41 PM
help im stupid
Report Abuse
theCJarmy7 is not online. theCJarmy7
Joined: 17 Jan 2015
Total Posts: 229
06 Feb 2016 10:44 PM
pick = game. --whatever
kill = game. --leaderstats or something
gold = game. -- leadersats or something
function onClicked(playerWhoClicked)
if game.Players.playerWhoClicked.kills > 2 and game.Players.playerWhoClicked.gold > 5 --whatever
then local pick = game.Lighting.pick:Clone();
pick.Parent = game.Players.playerWhoClicked.Backpack; --asuming the pick is in lighting
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)


this might not work, it was made entirely in this post
Report Abuse
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
06 Feb 2016 10:48 PM
You don't understand, I want it so that if you buy the "God Pickaxe" it ONLY takes away your "Gold" and not "Kills". But I still want the "Kills" to be a requirement to buy the "God Pickaxe"..
Report Abuse
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
06 Feb 2016 10:59 PM
I can see what you want based on your reply to the other person and this is probably how I would go and do it.

(Also, sorry if I didn't get exactly what you wanted, but this would probably be a cleaner version then the one you have.)

--In a script in ServerScriptService

game:GetService("Players").PlayerAdded:connect(function(p)
local leaderstats = Instance.new("Folder", p)
leaderstats.Name = "leaderstats"

local kills = Instance.new("IntValue", leaderstats)
kills.Name = "Kills"

local gold = Instance.new("IntValue", leaderstats)
gold.Name = "Gold"
end)

--In a localscript where you had the gui button
local button = script.Parent
local tool = game.Lighting:WaitForChild("God Pickaxe")

local plr = game.Players.LocalPlayer
local backpack = plr:WaitForChild("Backpack")
local starterGear = plr:WaitForChild("StarterGear")
local leaderstats = plr:WaitForChild("leaderstats")
local kills = leaderstats:WaitForChild("Kills")
local gold = leaderstats:WaitForChild("Gold")

local required = 2
local price = 5

button.MouseButton1Click:connect(function()
if (kills >= required and gold >= required) then
gold.Value = gold.Value = price
tool:clone().Parent = backpack
tool:clone().Parent = starterGear
end
end)
Report Abuse
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
06 Feb 2016 11:01 PM
The thing is, my original script is inside of a button which the button is inside of the shopGUI. So will this still work?
Report Abuse
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
06 Feb 2016 11:01 PM
I tried to conform it to the script you provided, so probably
Report Abuse
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
06 Feb 2016 11:07 PM
Does not work in a normal script, maybe a local script will work..
Report Abuse
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
06 Feb 2016 11:08 PM
Yes, a localscript for the button and normal script for the playeradded
Report Abuse
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
06 Feb 2016 11:10 PM
i already had the leaderstats. I just removed the playeradded script from the script. Maybe it will work now..
Report Abuse
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
06 Feb 2016 11:11 PM
I put the localscript inside of the button right?.....
Report Abuse
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
06 Feb 2016 11:13 PM
does not work..
Report Abuse
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
06 Feb 2016 11:15 PM
What does it say in the output?

And how about trying to put the server script that I provided into serverscriptservice and the button script into the button with a localscript.

It's not that hard to follow.
Report Abuse
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
06 Feb 2016 11:17 PM
replace the gold = gold = price line to gold.Value = gold.Value - price
sorry, minor mistake there
Report Abuse
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
06 Feb 2016 11:21 PM
Replace the entire button script with:

local button = script.Parent
local tool = game.Lighting:WaitForChild("God Pickaxe")

local plr = game.Players.LocalPlayer
local backpack = plr:WaitForChild("Backpack")
local starterGear = plr:WaitForChild("StarterGear")
local leaderstats = plr:WaitForChild("leaderstats")
local kills = leaderstats:WaitForChild("Kills")
local gold = leaderstats:WaitForChild("Gold")

local required = 2
local price = 5

button.MouseButton1Click:connect(function()
print("click")
if (kills.Value >= required and gold.Value >= required) then
gold.Value = gold.Value - price
tool:clone().Parent = backpack
tool:clone().Parent = starterGear
end
end)

--I tested it and this works
Report Abuse
Mezur is not online. Mezur
Joined: 29 Jun 2015
Total Posts: 3040
07 Feb 2016 12:36 AM
in a local script right?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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