i’m unsure if this works. i know my webhook works because i tested it out before. i don’t know if this will work:
local Datastore = game:GetService("DataStoreService")
local https = game:GetService("HttpService")
local url = (webhook url)
local data = Datastore:GetDataStore("data")
player = game.Players.LocalPlayer
local leadstats = Instance.new("Folder")
leadstats.Name = "leaderstats"
leadstats.Parent = player
playerUserId = "Player_"..player.UserId
local checkpoints1 = Instance.new("IntValue")
checkpoints1.Name = "Checkpointch1"
checkpoints1.Parent = leadstats
local temp = Instance.new("IntValue")
temp.Name = "temp"
temp.Parent = leadstats
local chapters = Instance.new("IntValue")
chapters.Name = "chapters"
chapters.Parent = player
game.Players.PlayerAdded:Connect(function(player)
local save
local success, errormsg = pcall(function()
save = data:GetAsync(playerUserId)
end)
if success then
checkpoints1.Value = save
chapters.Value = save
else
game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("DebugScreen"):WaitForChild("DebugFrame").Visible = true
warn(errormsg)
local webhookdata = {["embeds"] = {{
["title"] = "Error",
["description"] = "Something went wrong while loading data.", player.Name, chapters.Value, checkpoints1.Value}}}
local webhookmsg = https:JSONEncode(webhookdata)
https:PostAsync(url, webhookmsg)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormsg
success, errormsg = pcall(function()
local save
save = data:SetAsync(playerUserId)
if success then
checkpoints1.Value = save
print("Data saved")
else
game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("DebugScreen"):WaitForChild("DebugFrame").Visible = true
warn(errormsg)
local webhookdata = {["embeds"] = {{
["title"] = "Error",
["description"] = player.Name, "Something went wrong while saving data.", chapters.Value, checkpoints1.Value}}}
local webhookmsg = https:JSONEncode(webhookdata)
https:PostAsync(url, webhookmsg)
end
end)
end)
local Datastore = game:GetService("DataStoreService")
local https = game:GetService("HttpService")
local url = (webhook url)
local data = Datastore:GetDataStore("data")
player = game.Players.LocalPlayer
local leadstats = Instance.new("Folder")
leadstats.Name = "leaderstats"
leadstats.Parent = player
playerUserId = "Player_"..player.UserId
local checkpoints1 = Instance.new("IntValue")
checkpoints1.Name = "Checkpointch1"
checkpoints1.Parent = leadstats
local temp = Instance.new("IntValue")
temp.Name = "temp"
temp.Parent = leadstats
local chapters = Instance.new("IntValue")
chapters.Name = "chapters"
chapters.Parent = player
game.Players.PlayerAdded:Connect(function(player)
local save
local success, errormsg = pcall(function()
save = data:GetAsync(playerUserId)
end)
success = false
if success then
checkpoints1.Value = save
chapters.Value = save
else
game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("DebugScreen"):WaitForChild("DebugFrame").Visible = true
warn(errormsg)
local webhookdata = {["embeds"] = {{
["title"] = "Error",
["description"] = "Something went wrong while loading data.", player.Name, chapters.Value, checkpoints1.Value}}}
local webhookmsg = https:JSONEncode(webhookdata)
https:PostAsync(url, webhookmsg)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormsg
success, errormsg = pcall(function()
local save
save = data:SetAsync(playerUserId)
success = false
if success then
checkpoints1.Value = save
print("Data saved")
else
game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("DebugScreen"):WaitForChild("DebugFrame").Visible = true
warn(errormsg)
local webhookdata = {["embeds"] = {{
["title"] = "Error",
["description"] = player.Name, "Something went wrong while saving data.", chapters.Value, checkpoints1.Value}}}
local webhookmsg = https:JSONEncode(webhookdata)
https:PostAsync(url, webhookmsg)
end
end)
end)
local success,err = pcall(function()
local descText = “[!]: Something went wrong while saving %s data [%s, %s]”
local webhookdata = {[“embeds”] = {{
[“title”] = “Error”,
[“description”] = string.format(descText, “PLR NAME”, tostring(math.random(1, 10)), tostring(math.random(1, 10)))}}}
local webhookmsg = https:JSONEncode(webhookdata)
https:PostAsync(url_webhook, webhookmsg)
end)
if (err) then warn(err) end
Make new script and put that code and try also make sure ur url webhook is correct and make sure your game settings>Security>HTTPS API Access is set to allow.
Just return the player removing function using this. It’s good to use for databases as well. Jus read the article I sent to test it out. (When testing in studio sometimes it doesn’t exit out the game correctly)
“The game will wait a maximum of 30 seconds for all bound functions to complete running before shutting down. After 30 seconds, the game will shut down regardless if all bound functions have completed or not.”