How do you fix where a value is a child of something but the system does not see it?
Asked by
5 years ago Edited 5 years ago
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)
1 | local humanoid = script.Parent.Humanoid |
2 | humanoid.Died:Connect( function () |
3 | game.ServerStorage:WaitForChild( "Events" ).GiveXp:Fire( 100 , humanoid.creator.Value) |
(damage script)
01 | script.Parent.Touched:Connect( function (hit) |
02 | local DmgValues = { script.Dmg.Value, script.DmgCritical.Value, script.Dmg 2. Value, script.Dmg 3. Value, script.DmgCritical 2. Value } |
03 | local char = hit.Parent |
04 | local hum = char:FindFirstChild( "Humanoid" ) |
05 | local chance = math.random( 1 , #DmgValues) |
06 | if hum and char.Name ~ = script.Parent.Parent.Name then |
07 | hum.Health = hum.Health - DmgValues [ chance ] |
08 | script.Disabled = true |
10 | script.Disabled = false |
14 | local player = game.Players.LocalPlayer |
16 | if hit.Parent.Humanoid.Health < = 0 then |
17 | local creator = Instance.new( "ObjectValue" ) |
18 | creator.Name = "creator" |
19 | creator.Parent = hit.Parent.Humanoid |
20 | creator.Value = player |
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?