Okay im using the raycast script found in most weapons. However, im trying to make the weapon kill zombies and not people. The weapon works fine as long as its looking for humanoid but if i change humanoid to Zombie then 3 errors pop up:
19:13:44.526 - Script 'Players.Player.Backpack.Pistol-(12).Local Gui', Line 348 - global fire 19:13:44.527 - Script 'Players.Player.Backpack.Pistol-(12).Local Gui', Line 451 - global onButton1Down 19:13:44.527 - Script 'Players.Player.Backpack.Pistol-(12).Local Gui', Line 471 19:13:44.528 - Stack End
line 348: (this is in the damage section of code below) if humanoid.Health>0 then
line 451: fire(mouse.Hit.p+rndm)
line 471:
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
Once again the weapon works fine if you leave it as humanoid. Can someone explain how I can fix this? Thanks!
Heres The section that does damage I bolded the only word in the whole script I changed:
if hit~=nil then local humanoid=hit.Parent:FindFirstChild("**Zombie**") if humanoid~=nil then local damage=math.random(BaseDamage-(BaseDamage*.25),BaseDamage+(BaseDamage*.25)) if hit.Name=="Head" then damage=damage*1.3 elseif hit.Name=="Torso" then else damage=damage*.75 end if humanoid.Health>0 then local eplr=game.Players:playerFromCharacter(humanoid.Parent) local plr=game.Players:playerFromCharacter(sp.Parent) if eplr~=nil and plr~=nil then -- if eplr.TeamColor~=plr.TeamColor or eplr.Neutral or plr.Neutral then tagHumanoid(humanoid) humanoid:TakeDamage(damage) -- end else tagHumanoid(humanoid) humanoid:TakeDamage(damage) end end end