My script is supposed to give XP to a person that kills an NPC, however i've run into problems along the way.
(script i am having trouble with)
local humanoid = script.Parent.Humanoid
humanoid.Died:Connect(function()
game.ServerStorage:WaitForChild("Events").GiveXp:Fire(100, humanoid.creator.Value)
end)
(damage script)
script.Parent.Touched:Connect(function(hit)
local DmgValues = {script.Dmg.Value, script.DmgCritical.Value, script.Dmg2.Value, script.Dmg3.Value, script.DmgCritical2.Value}
local char = hit.Parent
local hum = char:FindFirstChild("Humanoid")
local chance = math.random(1, #DmgValues)
if hum and char.Name ~= script.Parent.Parent.Name then
hum.Health = hum.Health - DmgValues[chance]
script.Disabled = true
wait(0.5)
script.Disabled = false
-- THIS PART ONLY BELOW
local player = game.Players.LocalPlayer
if hit.Parent.Humanoid.Health <= 0 then
local creator = Instance.new("ObjectValue")
creator.Name = "creator"
creator.Parent = hit.Parent.Humanoid
creator.Value = player
end
end
end)
I always run into an issue here, where in the output it says, "creator is not a valid member of Humanoid"
although the explorer shows that the value is indeed inside the humanoid.
How do i make it so that the system will know that the "creator" value is there?
