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

My Datastore is not working, it said "Unable to cast array." Can anyone help?

Asked by 3 years ago

"Unable to cast to array." Is what I saw

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore")

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

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

    local Shaggy = Instance.new("IntValue")
    Shaggy = Instance.new("IntValue")
    Shaggy.Name = "Shaggy"
    Shaggy.Parent = Shaggys
    local DiscountShaggy = Instance.new("IntValue")
    DiscountShaggy.Name = "DiscountShaggy"
    DiscountShaggy.Parent = Shaggys
    local NeonPinkShaggy = Instance.new("IntValue")
    NeonPinkShaggy.Name = "NeonPinkShaggy"
    NeonPinkShaggy.Parent = Shaggys
    local CrimsonShaggy = Instance.new("IntValue")
    CrimsonShaggy.Name = "CrimsonShaggy"
    CrimsonShaggy.Parent = Shaggys
    local DiscountCrimsonShaggy = Instance.new("IntValue")
    DiscountCrimsonShaggy.Name = "DiscountCrimsonShaggy"
    DiscountCrimsonShaggy.Parent = Shaggys
    local FractalShaggy = Instance.new("IntValue")
    FractalShaggy.Name = "FractalShaggy"
    FractalShaggy.Parent = Shaggys
    local GradientShaggy = Instance.new("IntValue")
    GradientShaggy.Name = "GradientShaggy"
    GradientShaggy.Parent = Shaggys
    local LimeGreenShaggy = Instance.new("IntValue")
    LimeGreenShaggy.Name = "LimeGreenShaggy"
    LimeGreenShaggy.Parent = Shaggys
    local LiterallyShaggy = Instance.new("IntValue")
    LiterallyShaggy.Name = "LiterallyShaggy"
    LiterallyShaggy.Parent = Shaggys
    local NightShaggy = Instance.new("IntValue")
    NightShaggy.Name = "NightShaggy"
    NightShaggy.Parent = Shaggys
    local OrangeShaggy = Instance.new("IntValue")
    OrangeShaggy.Name = "OrangeShaggy"
    OrangeShaggy.Parent = Shaggys
    local PRShag = Instance.new("IntValue")
    PRShag.Name = "PRShag"
    PRShag.Parent = Shaggys
    local PShag = Instance.new("IntValue")
    PShag.Name = "PShag"
    PShag.Parent = Shaggys
    local RSh = Instance.new("IntValue")
    RSh.Name = "RSh"
    RSh.Parent = Shaggys
    local USShaggy = Instance.new("IntValue")
    USShaggy.Name = "USShaggy"
    USShaggy.Parent = Shaggys

    local PlayerUserId = "Player_"..player.UserId
    local DataShaggy
    local DataDiscountShaggy
    local DataNeonPinkShaggy
    local DataCrimsonShaggy
    local DataDiscountCrimsonShaggy
    local DataFractalShaggy
    local DataGradientShaggy
    local DataLimeGreenShaggy
    local DataLiterallyShaggy
    local DataNightShaggy
    local DataOrangeShaggy
    local DataPRShag
    local DataPShag
    local DataRSh
    local DataUSShaggy
    local success, errormessage = pcall(function()
        DataShaggy = DataStore:GetAsync(PlayerUserId)
        DataDiscountShaggy = DataStore:GetAsync(PlayerUserId)
        DataNeonPinkShaggy = DataStore:GetAsync(PlayerUserId)
        DataCrimsonShaggy = DataStore:GetAsync(PlayerUserId)
        DataDiscountCrimsonShaggy = DataStore:GetAsync(PlayerUserId)
        DataFractalShaggy = DataStore:GetAsync(PlayerUserId)
        DataGradientShaggy = DataStore:GetAsync(PlayerUserId)
        DataLimeGreenShaggy = DataStore:GetAsync(PlayerUserId)
        DataLiterallyShaggy = DataStore:GetAsync(PlayerUserId)
        DataNightShaggy = DataStore:GetAsync(PlayerUserId)
        DataOrangeShaggy = DataStore:GetAsync(PlayerUserId)
        DataPRShag = DataStore:GetAsync(PlayerUserId)
        DataPShag = DataStore:GetAsync(PlayerUserId)
        DataRSh = DataStore:GetAsync(PlayerUserId)
        DataUSShaggy = DataStore:GetAsync(PlayerUserId)
    end)
    if success then
        Shaggy.Value = DataShaggy
        DiscountShaggy.Value = DataDiscountShaggy
        NeonPinkShaggy.Value = DataNeonPinkShaggy
        CrimsonShaggy.Value = DataCrimsonShaggy
        DiscountCrimsonShaggy.Value = DataDiscountCrimsonShaggy
        FractalShaggy.Value = DataFractalShaggy
        GradientShaggy.Value = DataGradientShaggy
        LimeGreenShaggy.Value = DataLimeGreenShaggy
        LiterallyShaggy.Value = DataLiterallyShaggy
        NightShaggy.Value = DataNightShaggy
        OrangeShaggy.Value = DataOrangeShaggy
        PRShag.Value = DataPRShag
        PShag.Value = DataPShag
        RSh.Value = DataRSh
        USShaggy.Value = DataUSShaggy
    end
end)
game.Players.PlayerRemoving:Connect(function(player)
    local PlayerUserId = "Player_"..player.UserId
    local DataShaggy = player.Shaggys.Shaggy.Value
    local DataNeonPinkShaggy = player.Shaggys.NeonPinkShaggy.Value
    local DataDiscountShaggy = player.Shaggys.DiscountShaggy.Value
    local DataCrimsonShaggy = player.Shaggys.CrimsonShaggy.Value
    local DataDiscountCrimsonShaggy = player.Shaggys.DiscountCrimsonShaggy.Value
    local DataFractalShaggy = player.Shaggys.FractalShaggy.Value
    local DataGradientShaggy = player.Shaggys.GradientShaggy.Value
    local DataLimeGreenShaggy = player.Shaggys.LimeGreenShaggy.Value
    local DataLiterallyShaggy = player.Shaggys.LiterallyShaggy.Value
    local DataNightShaggy = player.Shaggys.NightShaggy.Value
    local DataOrangeShaggy = player.Shaggys.OrangeShaggy.Value
    local DataPRShag = player.Shaggys.PRShag.Value
    local DataPShag = player.Shaggys.PShag.Value
    local DataRSh = player.Shaggys.RSh.Value
    local DataUSShaggy = player.Shaggys.USShaggy.Value
    local success, errormessage = pcall(function()
        DataStore:SetAsync(PlayerUserId, DataShaggy, DataNeonPinkShaggy, DataDiscountShaggy, DataCrimsonShaggy, DataDiscountCrimsonShaggy, DataFractalShaggy, DataGradientShaggy, DataLimeGreenShaggy, DataLiterallyShaggy, DataNightShaggy, DataOrangeShaggy, DataPRShag, DataPShag, DataRSh)
  end
end)
0
what line is it? JesseSong 3916 — 3y
0
also, you're missing an ) on the end in line 127. JesseSong 3916 — 3y
0
I don't remember. But thanks, I'll add that one ")" SirWooff 0 — 3y

Answer this question