Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get get a NPC to jump when it touches a part but not when it touches a part in a player?

Asked by 7 years ago

Currently, I'm in the process of designing a NPC that I'm going to use for one of my games. However, this script isn't working the way I'd like it to. How ideas on how I could fix it? The whole point of the script is to make my NPC jump when it touches a part but not when it touches the part of a Player.



function onTouched(part) if part.Name ~= {"Torso","Left Arm","Right Arm","Left Leg","Right Leg","Head"} then script.Parent.Parent.Zombie.Jump = false if else script.Parent.Parent.Zombie.Jump = true end end end script.Parent.Touched:connect(onTouched)
0
Here try this:                                                                                                                          function onTouched(part)02  local Humanoid = part:FindFirstChild("Humanoid") if Humanoid == nil then03    script.Parent.Parent.Zombie.Jump = false04    if else05 06    script.Parent.Parent.Zombie.Jump = true07 08    end09 10 11    end12end13 14script.Parent.Touche justintubba123 6 — 7y
1
Remove the extra "if" next to else and remove an "end" Mayk728 855 — 7y
0
Thanks, I'll try that. Michael_TheCreator 166 — 7y
0
I tried both suggestions and still didn't have any success :'( Michael_TheCreator 166 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Try this;


local zombo = script.Parent.Parent:WaitForChild("Zombie") --Change this to the NPC zombo.Touched:Connect(function(Hit) if Hit.Parent.Name ~= {"Torso","Left Arm","Right Arm","Left Leg","Right Leg","Head"} then zombo.Jump = false else zombo.Jump = true end end)

This should work, if it helped please accept answer.

0
I copy and pasted that into a script and placed that inside the zombie's torso and it now it's not jumping at all. Maybe I'm doing something wrong? Michael_TheCreator 166 — 7y
Ad

Answer this question