Creator Value not working

Hello,

So I have a problem here, I made so that when my attack hits the mob, it creates a "creator’ value in his humanoid.

The creator value does get created, but it doesn’t set it’s value to the player’s name.


script.Parent.Touched:Connect(function(hit)

local Player = game.Players:GetPlayerFromCharacter(Character)

		local function TagHumanoid(humanoid, player)
		local Creator_Tag = Instance.new("ObjectValue")
		Creator_Tag.Name = "creator"
		Creator_Tag.Value = player
		game.Debris:AddItem(Creator_Tag, 2)
		Creator_Tag.Parent = humanoid
	end

	local function UntagHumanoid(humanoid)
		for i, v in pairs(humanoid:GetChildren()) do
			if v:IsA("ObjectValue") and v.Name == "creator" then
				v:Destroy()
			end
		end
	end

Humanoid:TakeDamage(DefaultDamage)
UntagHumanoid(Humanoid)
TagHumanoid(Humanoid, Player)

image

^
That doesn’t work


Any Help is appreciated!

How are you grabbing the Character object? I would guess that Player is null, thus creator.Value would also be null.

Also, is this a local or Server script?

1 Like

To get the character, I just did this:

local character = hit.Parent

And it is a Server Script inside a part.


Sorry for the late reply, had to go somewhere