I just figured out how to use coroutines, so I made a little script that levels you up to 1 when your exp changes to anything higher than 0.
BUT I get this error: Workspace.Script:14: attempt to call upvalue 'level' (a thread value) , and I don't know why..
Here's the script:
local level = coroutine.create(function(level) level.Value = level.Value + 1 end)
game.Players.PlayerAdded:connect(function(plr)
local lvl = Instance.new("IntValue", plr)
lvl.Name = "Level"
lvl.Value = 0
local expx = Instance.new("IntValue", plr)
expx.Name = "Exp"
expx.Value = 0
expx.Changed:connect(function()
coroutine.resume(level(lvl))
end)
end)

1 comment
yeah, i just wanted to try it out xd