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

How do I fix this script no errors come up in the console?

Asked by 4 years ago

Hello, I don't know why this script isn't working can someone please help. Someone told me to add BindToClose but I'm not sure where to add it.

Can someone please tell me what's wrong with the script or where to add the BindToClose. No errors show in the console.

Script:

local DataStoreService = game:GetService("DataStoreService")

local myDataStore = DataStoreService:GetDataStore("myDataStore")

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local jumps = Instance.new("IntValue")
    jumps.Name = "Jumps"
    jumps.Parent = leaderstats

    local data
    local success, errormessage = pcall(function()
        data = myDataStore:GetAsync(player.UserId.."-jumps")
    end)

    if success then
        jumps.Value = data
    else
        warn(errormessage)
        print("There was an error whilst getting your data")
    end
end)

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

    local success, errormessage = pcall(function()
    myDataStore:SetAsync(player.UserId.."-jumps", player.leaderstats.Jumps.Value)
    end)

    if success then
        print ("Data Saved Successfully")
    else
        print("There was an error when saving")
        warn(errormessage)
    end
end)
0
Use BindToClose is a DataModel's function. ~~~~~~~~~~~~~~~~~ game:BindToClose(function) ~~~~~~~~~~~~~~~~~ Sonnenroboter 336 — 4y
0
Use BindToClose is a DataModel's function. ~~~~~~~~~~~~~~~~~ game:BindToClose(function) ~~~~~~~~~~~~~~~~~ Sonnenroboter 336 — 4y

Answer this question