Here's the script:
player = game.Players.LocalPlayer Bought = script.Parent.Bought Bought.Value = false local HireCost = Instance.new("IntValue") HireCost.Parent = player HireCost.Value = 10 script.Parent.MouseButton1Click:connect(function(Building) local leaderstats = player:FindFirstChild("leaderstats") local mg = script.Parent:WaitForChild("HireMoney") if leaderstats.Cash.Value >= HireCost.Value then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - HireCost.Value if Bought.Value == false then Bought.Value = true HireCost.Value = HireCost.Value*2 mg.Value = mg.Value + 1 end script.Parent.Text = 'Hire Bil for $'..HireCost.Value end end)
There is also another script in the button:
while true do local player = game.Players.LocalPlayer Bought = script.Parent.Bought local mg = script.Parent:WaitForChild("HireMoney") wait(0.5) if Bought.Value == true then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + mg.Value elseif Bought.Value == false then --Nothing Should Happen If It Has Not Been Bought end end
It works perfectly in studio, but doesn't work in-game.This is a Local Script. Please fix this. Thanks!
You could try to see if this works:
player = game.Players.LocalPlayer Bought = script.Parent.Bought Bought.Value = false local HireCost = Instance.new("IntValue") HireCost.Parent = player HireCost.Value = 10 script.Parent.MouseButton1Click:connect(function(Building) local leaderstats = player:FindFirstChild("leaderstats") local mg = script.Parent:WaitForChild("HireMoney") if leaderstats.Cash.Value >= HireCost.Value then if Bought.Value == false then Bought.Value = true HireCost.Value = HireCost.Value*2 mg.Value = mg.Value + 1 end player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - HireCost.Value end end)
And Put This Into Another localscript with the same parent as you other script:
while true do local player = game.Players.LocalPlayer Bought = script.Parent.Bought local mg = script.Parent:WaitForChild("HireMoney") wait(0.5) if Bought.Value == true then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + mg.Value end elseif Bought.Value == false then --Nothing Should Happen If It Has Not Been Bought end end