The Bind To Close Function Is not working For Some Reason
game:BindToClose(function() local RunService = game:GetService("RunService") if RunService:IsStudio() then print("HAHA STUDIO") return end local Players = game:GetService("Players") for _, player in pairs(Players:GetPlayers()) do local Stats = player.LevelingSystem:GetChildren() local datastore = game:GetService("DataStoreService"):GetDataStore(player.UserId.."Stats") local statstorage = player:FindFirstChild("LevelingSystem"):GetChildren() local success , err = pcall(function() datastore:SetAsync("Lvl",statstorage.Lvl.Value) print("stat number 1 has been changed") datastore:SetAsync("XP",statstorage.XP.Value) print("stat number 2 has been changed") datastore:SetAsync("Money",statstorage.Money.Value) print("stat number 3 has been changed") datastore:SetAsync("EggHunter",statstorage.EggHunter.Value) print("stat number 4 has been changed") datastore:SetAsync("PreAlpha",statstorage.PreAlpha.Value) print("stat number 5 has been changed") datastore:SetAsync("Rank",statstorage.Rank.Value) print("stat number 6 has been changed") datastore:SetAsync("Missions",statstorage.Missions.Value) print("stat number 7 has been changed") datastore:SetAsync("Time",statstorage.Time.Value) print("stat number 8 has been changed") datastore:SetAsync("Banned",statstorage.Banned.Value) print("stat number 9 has been changed") datastore:SetAsync("BanR",statstorage.BanR.Value) print("stat number 10 has been changed") end) end end)