Ok, so if you have seen me before on the forums, you know I have almost no knowlegde of Luau. So I tried to make something where the player joins and they get 5 “Bucks” every 60 seconds. I know this doesn’t work but how can I make it work?
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Bucks = Instance.new("IntValue")
Bucks.Name = ("Bucks")
Bucks.Parent = leaderstats
local Time = Instance.new("IntValue") -- ignore this its just for something else
Time.Name = ("Time in server")
Time.Parent = leaderstats
-- how would i make it so that when the player joins, this would apply to them
while true do
Bucks.Value = Bucks.Value + 5
wait(60)
end
end
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Bucks = Instance.new("IntValue")
Bucks.Name = ("Bucks")
Bucks.Parent = leaderstats
local Time = Instance.new("IntValue") -- ignore this its just for something else
Time.Name = ("Time in server")
Time.Parent = leaderstats
-- how would i make it so that when the player joins, this would apply to them
while wait(60) do
player.leaderstats.Bucks.Value = Bucks.Value + 5
end
end)
ROBLOX doesn’t use Lua. They use Luau which has modifications which are not really documented anywhere. You have to google “ROBLOX compound operators” to find out about this feature.
Luau now supports compound assignments ( += , -= , *= , /= , %= , ^= and ..= ). The assignments only work on single values ( a, b += 1 is invalid); the left hand side is only evaluated once. When modifying table keys, __index and __newindex will be called as necessary - no new metamethods are introduced.