This is supposed to add money to the money int value in the leaderstats when it touched the brick at the end of my tycoon thingy. It was working, but not anymore? Any ideas?
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model",player)
leaderstats.Name = "leaderstats"
local money = Instance.new("IntValue", leaderstats)
money.Name = "Money"
money.Value = 0
function addMoney(b)
if b.Name == "MONEYBRICK" then
money.Value = money.Value + 5
if game.Workspace.UPGRADE1.Touched and b.Name == "MONEYBRICK" then
money.Value = money.Value + 5
end
end
end
function buyupgrade1()
if money.Value >= 50 then
money.Value = money.Value - 50
c = game.Lighting.UPGRADE1:Clone()
wait(.5)
c.Parent = game.Workspace
game.Workspace.pp:Destroy()
c.Transparency = 0.7
wait(1)
c.Transparency = 0.5
wait(1)
c.Transparency = 0.3
wait(1)
c.Transparency = 0
end
end
end)
game.Workspace.pp.Touched:connect(buyupgrade1)
game.Workspace.HITPART.Touched:connect(addMoney)

3 comments
Have you tried taking the function addMoney() out of your PlayerAdded one?
^ Yes, you probably want to take it out of the 'PlayerAdded' Function.
How do i get the money value outside of the main function though?