This script is located inside of the player and will only trigger if the player is in combat and leaves the game. Their data will be wiped. There are some problems though, sometimes the script doesn't even print anything. On the off chance it does, it doesn't even wipe data. Can anyone tell me why this will not work?
local ts = game:GetService("DataStoreService"):GetDataStore("ToolSave")
local gs = game:GetService("DataStoreService"):GetDataStore("GoldSave")
local ss = game:GetService("DataStoreService"):GetDataStore("SatrSave")
game.Players.PlayerRemoving:Connect(function(plr)
print(plr.Name.." COMBAT LOGGED.")
local key = "ID- "..plr.UserId
local key2 = plr.UserId
local key3 = "PID-"..plr.UserId
gs:RemoveAsync(key2)
ss :RemoveAsync(key3)
ts:RemoveAsync(key)
print("DATA WIPED")
end)

1 comment
Try placing the script at the workspace, or ServerScriptService [Normal Script, not local]