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

A weapon is not doing damage to a Zombie because of the Humanoid's name. Could you please help?

Asked by 10 years ago

I have to change the weapon's script, because if I re-name the Humanoid "Zombie" to Humanoid "Humanoid", the zombie would take damage, but will not follow anyone. If the Humanoid is left as "Zombie", if will follow and kill players, other models with humanoids, however any attempt to kill it with that weapon would fail. This issue has stumped me for two days, and is very gamebreaking. Here are snippets of code:

The Weapon (Raycasting Gun)

~~~~~~~~~~~~~~~~~ function raycast(startp, endp, ign) local vec=(endp-startp) if vec.magnitude<1000 then local hit,pos=game.Workspace:FindPartOnRay(Ray.new(startp,vec),ign) if hit and pos then if hit.Parent.className=="Tool" or hit.Parent.className=="Hat" then if hit.Parent.Parent ~= nil then if hit.Parent.Parent:findFirstChild("Humaniod")~=nil then return hit.Parent, pos end end elseif string.lower(hit.Name)=="glass" then local vec=(endp-pos) hit,pos=raycast(pos,vec,ign) elseif string.lower(hit.Name)=="water" then local vec=(endp-pos) hit,pos=raycast(pos,vec,ign) elseif hit.Transparency==1 or hit.Name=="Bullet" or hit.Name=="BulletTexture" then local vec=(endp-pos) hit,pos=raycast(pos,vec,hit) end end return hit,pos end return nil

end

function tagHumanoid(humanoid) local plr=game.Players:playerFromCharacter(sp.Parent) if plr~=nil then local tag=Instance.new("ObjectValue") tag.Value=plr tag.Name="creator" tag.Parent=humanoid delay(2,function() if tag~=nil then tag.Parent=nil end end) end end

~~~~~~~~~~~~~~~~~

And the script of the zombie: local larm = script.Parent:FindFirstChild("Left Arm") local rarm = script.Parent:FindFirstChild("Right Arm")

function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = 1000 local temp = nil local human = nil local temp2 = nil for x = 1, #list do temp2 = list[x] if (temp2.className == "Model") and (temp2 ~= script.Parent) then temp = temp2:findFirstChild("Torso") human = temp2:findFirstChild("Humanoid") if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then if (temp.Position - pos).magnitude < dist then torso = temp dist = (temp.Position - pos).magnitude end end end end return torso end

function Hit(hit) if hit.Parent ~= nil then local human1 = hit.Parent:findFirstChild("Humanoid") if human1 ~= nil then human1.Health = human1.Health -15 end end end

larm.Touched:connect(Hit) rarm.Touched:connect(Hit)

--wait(math.random(0,5)/10) while true do wait(0.5) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then script.Parent.Zombie:MoveTo(target.Position, target) end end

I can't really script, but I know a few things about scripting. If you need more information, I'll happily provide it. Could you please provide a few pointers on this problem? Thank you!

1 answer

Log in to vote
0
Answered by
painzx3 43
10 years ago

If I'm correct all you have to do is change the name of the "Humanoid" in the zombie to whatever it says in the script for the gun. Usually called "shooter" but if not then try finding the script that has stats for the gun such as damage or range.

0
and change "humaniod" to "Humanoid" painzx3 43 — 10y
0
You don't get it: whenever I change it to Humanoid, the zombie glitches. Bladeor 0 — 10y
Ad

Answer this question