I'm making a jail system and for some reason my datastore just refuses to work when the player leaves, it works every other time though.
Code:
game.Players.PlayerRemoving:Connect(function(plr) print("a") print(game:GetService("ReplicatedStorage").ArrestTimes[plr.Name].Value) ArrestDS:SetAsync(plr.Name .. ":" .. plr.UserId, game:GetService("ReplicatedStorage").ArrestTimes[plr.Name].Value) print("hi") print(ArrestDS:GetAsync(plr.Name .. ":" .. plr.UserId)) print("hi") end)
Wasn't able to fix this, And couldn't really bother too. I redid it and not sure if it works. But an issu
game.Players.PlayerRemoving:connect(function(plr) local TimesArrested = game:GetService(ReplicatedStorage").ArrestTimes[plr.Name].Value print(plr.Name .. "Left, Saving stats, Times Arrest: " .. TimesArrested) ArrestDS:SetAsync(plr.Name .. ":" .. plr.UserId, TimesArrested print("Succesfully saved the stats of the player : " .. plr.Name) end)