Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 28 Jul 2016 09:46 PM |
--Variables: local figure1 = game.Workspace:WaitForChild("Figure") local humanoid1 = figure1:WaitForChild("Humanoid") local figure2 = figure1.Parent:WaitForChild("Figure2") local humanoid2 = figure2:WaitForChild("Humanoid") -- game.Workspace.ChildAdded:connect(function(child) --Since the NPCs respawn, this will check for their new models and change figure1 and figure2 to the new model. if child.Name == "Figure" then figure1 = child humanoid1 = child:WaitForChild("Humanoid") elseif child.Name == "Figure2" then figure2 = child humanoid2 = child:WaitForChild("Humanoid") end end)
humanoid1.Changed:connect(function(c)--When figure1's humanoid is changed, if c == "Health" then --If that change was its health then if humanoid1:FindFirstChild("creator") ~= nil then--Check if it has a value named "creator" in it. The sword makes a value go inside the humanoid stating who hit it. :) local value = humanoid1.creator.Value print(value) local playerchar = game.Workspace:WaitForChild(value)--Find the person's character of the value who said who hit it. local torso = playerchar.Torso--Get that person's torso. humanoid2:MoveTo(torso.Position)--Make figure2 walk to their torso position! (This will make it so it walks to the player by the way) playerchar.Humanoid:TakeDamage(10)--After the player has been reached, inflict damage! end end end)
Every time I go to read the tag it keeps erroring that what I'm looking for is nil.
I feel like I'm reading the tags wrong- Am I?
u sicko! |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2016 09:51 PM |
Does the print(value) work? It should, but if not print(value.Name)
local playerchar = game.Workspace:WaitForChild(value.Name) |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 28 Jul 2016 10:09 PM |
IT PRINTS MY NAME, YET IT SAYS IT IS NIL WHY
u sicko! |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2016 10:14 PM |
| FindFirstChild() is looking for a string, not a Player object. |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 28 Jul 2016 10:16 PM |
How do I get the player then?
u sicko! |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2016 10:21 PM |
player.Name
This siggy is copyrighted © |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2016 10:22 PM |
Hmm, I must be missing something. I assume that the "creator" tag is an ObjectValue named "creator", right? So either the ObjectValue is never being inserted into the humanoid, or its Value is never being assigned. If you already checked both then I'm just as confused as you are. Also, I have run into problems with :WaitForChild() in the past, it may be better to use something else instead if its not working. |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 28 Jul 2016 10:24 PM |
I figured it out, the value was the actual player itself. Never using ObjectValues again.
u sicko! |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2016 10:27 PM |
| Oh wow, that's what I was trying to say the whole time. I need to be WAAAAAAAY more specific next time. |
|
|
| Report Abuse |
|
|