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
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
|
| 06 Feb 2016 10:38 PM |
| bump.......................... |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 06 Feb 2016 11:01 PM |
| I tried to conform it to the script you provided, so probably |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 06 Feb 2016 11:08 PM |
| Yes, a localscript for the button and normal script for the playeradded |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|
|
| 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 |
|
|
|
| 06 Feb 2016 11:17 PM |
replace the gold = gold = price line to gold.Value = gold.Value - price sorry, minor mistake there |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|