So I made a button that is supposed to disappear when you touch it, it gives the player +5 money every minute or so, it doesn't disappear when you touch it and the money doesn't add 5 to the player, I made the Humanoid and the Head which are inside the button model. I have also made a money leaderboard.
Script from button:
-------------------------------------------------------------------------------------------------------------------------
Upgrade = script.Parent.Parent.Parent.Income
Upgradecost = 0
UpgradeThing = 5
-------------------------------------------------------------------------------------------------------------------------
wait(1)
owner = script.Parent.Parent.Parent.OwnerName
local ting = 0
function onTouched(hit)
if ting == 0 then
ting = 1
check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
if hit.Parent.Name == owner.Value then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:findFirstChild("Money")---But only you can change leaderstats!
if cash.Value > (Upgradecost-1) then
cash.Value = cash.Value - Upgradecost
Upgrade.Value = Upgrade.Value + UpgradeThing
script.Parent.Parent:remove()
end
end
end
end
ting = 0
end
end
script.Parent.Touched:connect(onTouched)
Script from money leaderboard:
game.Players.ChildAdded:connect(onPlayerEntered)
function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local cash = Instance.new("IntValue")
cash.Name = "Money"
cash.Parent = stats
stats.Parent = newPlayer
end
game.Players.ChildAdded:connect(onPlayerEntered)
Please tell me what's wrong.
