Why does objectValue have an empty Value?

I need the creator to have the nickname of the player who killed another player in Value

For some reason, the lines that I inserted into the script do not work with Value. Everything seems to be correct, but for some reason it doesn’t work.
Here is my script:

canattack = true
cananimate = false
equipped = false
tool = script.Parent
handle = tool.Handle
equipsound = handle.Equip
swishsound = handle.Swoosh
hitsound = handle.Hit
goresound = handle.Ouch
hitsound2 = handle.Hit2
goresound2 = handle.Ouch2
owner = nil
character = nil
mouseclick = false
attacknumber = 1
attacktype = 0
count = 0
trail = handle.Trail
runservice = game:GetService("RunService")
local vCharacter = tool.Parent
local vPlayer = game.Players:GetPlayerFromCharacter(vCharacter)
--
tool.Activated:connect(function()
	mouseclick = true
end)
tool.Deactivated:connect(function()
	mouseclick = false
end)
--
function ragdollkill(character)
	local victimshumanoid = character:findFirstChildOfClass("Humanoid")
	local checkragd = character:findFirstChild("ragded")
	if not checkragd then
		local boolvalue = Instance.new("BoolValue", character)
		boolvalue.Name = "ragded"
		if not character:findFirstChild("UpperTorso") then
			character.Archivable = true
			for i,v in pairs(character:GetChildren()) do
				if v.ClassName == "Sound" then
					v:remove()
				end
				for q,w in pairs(v:GetChildren()) do
					if w.ClassName == "Sound" then
						w:remove()
					end
				end
			end
			local ragdoll = character:Clone()
			for i,v in pairs(ragdoll:GetDescendants()) do
				if v.ClassName == "Motor" or v.ClassName == "Motor6D" then
					v:destroy()
				end
			end
			ragdoll:findFirstChildOfClass("Humanoid").BreakJointsOnDeath = false
			ragdoll:findFirstChildOfClass("Humanoid").Health = 0
			local creator_tag = Instance.new("ObjectValue", character.Humanoid)
			creator_tag.Name = "creator"
			creator_tag.Value = vPlayer
		--then there are other unnecessary lines

P.S. the script is very strange and wretched, but it works, I only need an answer to the question about Value


thank you in advance

Hi! The problem in these lines

local vCharacter = tool.Parent
local vPlayer = game.Players:GetPlayerFromCharacter(vCharacter)

At the start, tool’s parent is Player’s Backpack
And if you try to get player from Backpack, it just give you nil
Here’s solution: local vPlayer = tool.Parent.Parent
Or (if code in localscript) local vPlayer = game:GetService("Players").LocalPlayer

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.