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

There are output errors in my script and I am unsure of how to fix it. How do I fix it?

Asked by
Comqts 6
2 years ago
local DataStore = game:GetService("DataStoreService")
local PointsData = DataStore:GetDataStore("POINTSDATA")



game.Players.PlayerAdded:Connect(function(player)
    local Data1 = PointsData:GetAsync(player.UserId)
    local datastats = Instance.new("Folder")
    datastats.Name = "leaderstats"
    datastats.Parent = player

    local Points = Instance.new("IntValue")
    Points.Name = "Points"
    Points.Parent = datastats

    local Coins = Instance.new("IntValue")
    Coins.Name = "Coins"
    Coins.Parent = datastats



    local success, error1 = pcall(function()
        PointsData:GetAsync(player.UserId)
    end)

    if success then
        Points.Value = datastats.Points
        Coins.Value = datastats.Coins
    end
    local groupid = 12185953
    if player:GetRankInGroup(groupid) >= 5 then
        while task.wait(3) do
            Points.Value += 100
        end
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    PointsData:SetAsync(player.UserId, {
        ["Points"] = player.datastats.Points.Value,
        ["Coins"] = player.datastats.Coins.Value,
        ["Rank"] = player.datastats.Rank.Value
    })
end)

So basically, I'm making it so it saves the points and coins. I have an output. "Unable to assign property Name. string expected, got Instance " and "datastats is not a valid member of Player "Players.Comqts""

Answer this question