Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to fix datastore not sending when player leaves?

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)

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.