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

why doesnt this ordereddatastore kill script work?

Asked by 6 years ago

so whenever a player dies its supposed to add 1 to the player's ordereddatastore but this shows up

https://gyazo.com/b5a29f5b2b6360fc3613f12e75e2fedf

local ods = game:GetService("DataStoreService"):GetOrderedDataStore("HSKills")
local hum = script.Parent

function change()
    local tag = hum:FindFirstChild("creator")
    if tag ~= nil then
        if tag.Value ~= nil then
            local plr = game.Players[tag.Value]
            ods:IncrementAsync(plr,1)
        end
    end
end

hum.Died:connect(change)
0
My guess is that creator is not a StringValue object but an ObjectValue. The hint? The error talks about using userdata. The value object of StringValue would be a string. You didn't tell us what the creator tag is so we cannot help you at the moment. What is the creator tag? User#18718 0 — 6y

1 answer

Log in to vote
0
Answered by
xPolarium 1388 Moderation Voter
6 years ago

I haven't worked with OrderedDataStore's at all but it looks okay to me while comparing this to the wiki.

Anyways the problem on Line 8 is that its only getting the Player from the Players service. You need the name of that player or a key.

Simply on line 8:

local plr = game.Players[tag.Value].Name

I don't think you should use the Name of the player as the key since the player is able to just change his name at any time.

0
By the way, you can get around a lot of the errors by just searching the meaning of it on google (Usually will be lead to the forums or documented on roblox wiki). xPolarium 1388 — 6y
0
didnt work rip ninjaguy77777 -6 — 6y
Ad

Answer this question