ello, I am greatneil80...... As you see, i have this button and.. when the button is pressed, it adds some money....
Then, in a gui when I click a button, it subtracts money but when I attempt to get more, it becomes the previous value + 1 example: Gold = 100 then.. clicked gui.. gold = 0 then.. attempt for gold.. gold = 101 why is that happening ^ ;-;
script 1: Gui -- don't bother looking at the function.....
math.randomseed(tick())--So math.random doesn't repeat over again
local cooldown = script.Parent:WaitForChild("CoolDown")-- so that the monsters don't flick out from the map :3
gold = game:GetService("Players").LocalPlayer.leaderstats.Gold -- getting the players gold
wait(1)
local plr = game:GetService("Players").LocalPlayer
function RunScript() -- make a function
local a = game.ReplicatedFirst.CharactersLevelOne:GetChildren() -- folder in server storage called characters level one, i get all the items from it and....
local b = a[math.random(1,#a)]:Clone() -- i get math.random and choose one from that folder
print("Before Result")
wait(.1)
if plr.SaveMonsters:FindFirstChild(b.Name) then
print("After Result")
print(b.Name) -- search through a load of saving intvalues in a player
local monster = plr.SaveMonsters:FindFirstChild(b.Name) -- if the name matches the item got then...
print(b.Name)
if monster then
print(monster.Value)
monster.Value = monster.Value + 1 -- add a value
end
print(monster.Value)
print("Made My way through the dang script")
else
print("A rare monster isn't named on the list and cannot be Summoned")
end
local great = workspace.MOSTOFTHESCRIPTSAREHERE.PlayersMonsterLimit -- a variable that shows u the max amount of items u can have, so if u get an item it will add a count / 10
great.Value = great.Value + 1 -- add a value
if great.Value >= 10 then -- if great is over 10 then
wait(.01)
script.Disabled = true -- disable the script
if great.Value > 10 then -- if it is MORE than 10 then destroy the "b"
b:Destroy()
end
end
script.Parent.Parent:WaitForChild("FirstSummon").Text = "You Got.. "..b.Name
wait(1)
script.Parent.Parent:WaitForChild("FirstSummon").Text = "Buy Miniature Scroll (Beta)"
b.Parent = workspace.Monsters -- then move its parent to a folder in workspace
gold.Value = gold.Value - 100 -- remove money from the player
end
script.Parent.MouseButton1Click:connect(function() -- now, when button pressed :P
if gold.Value >= 100 then
cooldown.Visible = true
RunScript()
wait(1.5)
cooldown.Visible = false
end
if gold.Value < 99 then
script.Parent.Parent.FirstSummon.Text = "Not enough money"
wait(3)
script.Parent.Parent.FirstSummon.Text = "1 ~ 3 100 gold"
end
end)
script 2: money adder (In a part)
script.Parent.PartClicker.MouseClick:connect(function(player)
local stats = player:findFirstChild("leaderstats")
local gold = stats:findFirstChild("Gold")
if gold then
gold.Value = gold.Value + 1
print("Adding + 1 to current Value")
end
end)

2 comments
I have 3 questions. 1) Why all the new empty lines? 2) Why a mix of :findFirstChild and :FindFirstChid? 3) Someone could use autoclicker...... just saying
^ it is very complicating, actually ima take down the question because it is FE's fault that it won't change