Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What does Not running script because past shutdown deadline mean?

Asked by 5 years ago

local datastore = game:GetService("DataStoreService"):GetDataStore("MoneyDataStore") local defaultcash = 0 local playersleft = 0

game.Players.PlayerAdded:Connect(function(player)

playersleft = playersleft + 1

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local bucks = Instance.new("IntValue")
bucks.Name = "Money"
bucks.Value = 0
bucks.Parent = leaderstats


player.CharacterAdded:Connect(function(character)
    character.Humanoid.WalkSpeed = 16
    character.Humanoid.Died:Connect(function()
        -- Whenever someone dies this happens

        if character.Humanoid and character.Humanoid:FindFirstChild("creator") then
            game.ReplicatedStorage.Status.Value = tostring(character.Humanoid.creator.Value).." Killed "..player.Name
        end

        if character:FindFirstChild("GameTag") then
            character.GameTag:Destroy()
        end

        player:LoadCharacter()
    end)

end)

-- Data Store

local player_data

pcall(function()
    player_data = datastore:GetAysnc(player.UserId.."-Money")
end)

if player_data ~= nil then
    --Player has saved data, load it in
    bucks.Value = player_data
else
    -- New player
    bucks.Value = defaultcash
end

end)

local bindableEvent = Instance.new("BindableEvent")

game.Players.PlayerRemoving:Connect(function(player)

pcall(function()
    datastore:SetAsync(player.UserId.."-Money",player.leaderstats.Money.Value)
    print("Saved")
    playersleft = playersleft - 1
    bindableEvent:Fire()
end)

end)

game:BindToClose(function() -- This will be triggerd upon shutdown while playersleft > 0 do bindableEvent.Event:Wait() end end)

My script is saying: Not running script because past shutdown deadline

0
I think it was because the data wasn't saving in time tyorange09 4 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

It was because I misspelled Async in the final pcall.

Ad

Answer this question