Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if script.Parent:IsA("Actor") then
- local bindable = script.Parent.Parent:WaitForChild("Bindable")
- local playerToSave
- local connection
- connection = bindable.Event:Connect(function(player)
- if player.Name == script.Parent.Name then
- playerToSave = player
- connection:Disconnect()
- connection = nil
- end
- end)
- task.desynchronize()
- local tries = 0
- local max = 5
- repeat wait(6)
- local s, e = pcall(function()
- DS:SetAsync(UUID, player.Data)
- end)
- tries += 1
- until s or tries >= max
- task.synchronize()
- end
- game:BindToClose(function()
- if script.Parent:IsA("Actor") then return end
- local bindable = Instance.new("BindableEvent")
- bindable.Name = "Bindable"
- bincable.Parent = script
- for _,player in pairs(game:GetService("Players"):GetPlayers()) do
- local actor = Instance.new("Actor")
- actor.Name = player.Name
- script:Clone().Parent = Actor
- actor.Parent = script
- bindable:Fire(player)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement