1.
model = script.Parent.Parent
backup = model:clone()
enabled = true
function regenerate()
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("leaderstats")
local cash = stats:findFirstChild("Gold")
if stats ~= nil then
if cash.Value > (199) then
cash.Value = cash.Value - 200
model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
script.Disabled = true
script.Parent.BrickColor = BrickColor.new(26)wait(5)
script.Parent.BrickColor = BrickColor.new(104)
script.Disabled = false
end
end
end
function onHit(hit)
if (hit.Parent:FindFirstChild("Humanoid") ~= nil) and enabled then
regenerate()
end
end
script.Parent.Touched:connect(onHit)
Script woking!
I added lines
local stats = user:findFirstChild("leaderstats")
local cash = stats:findFirstChild("Gold")
if stats ~= nil then
if cash.Value > (199) then
cash.Value = cash.Value - 200
And script dont work...
Leader stats have "Gold" and problem is 99% in regen script
/////////////////////////////////////////////////////////////////////////////
2.
Upgradecost = 100
local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:findFirstChild("Gold")
if cash.Value > (Upgradecost-1) then
cash.Value = cash.Value - Upgradecost
script.Parent:clone().Parent = player.Backpack
wait(2)
debounce = false
end
end
end
end
script.Parent.Parent.Touched:connect(onTouch)
Same as 1.
Upgradecost = 100
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:findFirstChild("Gold")
if cash.Value > (Upgradecost-1) then
cash.Value = cash.Value - Upgradecost
Dont work... |