Hello! So i want to create a game similar to cookie clicker but instead of cookies there are balls, but im having a little problem.
So im trying to make a passive income that generates balls every second but there is a bug. Here are the scripts (they are all in ServerScriptService):
add Balls value inside the player-
game.Players.PlayerAdded:Connect(function(plr)
local Balls = Instance.new("IntValue", plr)
Balls.Name = ("Balls")
Balls.Value = 1
end)
add BPS (Balls Per Second) value inside the player-
game.Players.PlayerAdded:Connect(function(plr)
local BPS = Instance.new("IntValue", plr)
BPS.Name = ("BallsPerSecond")
BPS.Value = 1
end)
Passive income script-
game.Players.PlayerAdded:Connect(function(plr)
local BPS = plr.BPS
local Balls = plr.Balls
while true do
wait(1)
Balls.Value = Balls.Value +(BPS)
end
end)
So the bug is that when i playtest the game, console says that Balls and BPS values are not a valid member of a player, when they are. This could be caused by studio loading this script first before the scripts that add Balls and BPS values inside the player. So is there any way i can pause the passive income script for it to wait for other scripts?