Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why doesnt this ordereddatastore kill script work?

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)

1 comment

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?

1 answer

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.

2 comments

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).

0

didnt work rip

This discussion is preserved as it was. New answers, comments, and votes are closed.