i use BindToClose so should i use PlayerRemoving ?
Use both, BindToClose functions run when the server shuts down, but not when a player leaves, so you have to use both
It right ?
game:BindToClose(function()
for i,plr in pairs(game.Players:GetPlayers()) do
coroutine.wrap(savedata(plr))
end
end)
Problem there, the coroutine.wrap()
function returns a function, it doesn’t call a function
game:BindToClose(function()
for i,plr in pairs(game.Players:GetPlayers()) do
coroutine.wrap(savedata)(plr) -- as you see, I did coroutine.wrap()() instead of coroutine.wrap(()), this is because the function returns a function, it doesn't call a function
end
end)
it still not work… too hard with me
Then take away the coroutine.wrap
, it was only there so we can save everyones data at once, but since it isn’t working, just take it away, and do saveData(plr)
your mean is
game:BindToClose(function()
for i,plr in pairs(game.Players:GetPlayers()) do
savedata(plr)
end
end)
yes, like that, try it and see if it works
It would be much more helpful if you posted your whole code in a code block to the forums instead of an image so we can actually scroll through it. Furthermore, providing details is also crucial to helping you out: in the OP, all you said is “it doesn’t work” but don’t say anything about how it doesn’t work. As a result, it seems your problems have extended far beyond one as per the ongoing discussion. Make sure you do some debugging and research on your own code first before posting threads.
Running tostring on a numeric DataStore key is not necessary because it will automatically be coerced into a string value on the backend. You’d be saving a negligible amount of work by doing this, but it’s not a requirement and also not a related problem.