Hello everyone, I have problem with script in gun. I want to change humanoid on zombie, becouse monsters hitting other monsters, so it's anoying. When i change in monster humanoid on zombie - i can't hurt them... It's not my script. Weapon created by WIJ. It's not all script, becouse max characters are 10,000, but i think in these lines. Here is script, if someone can show/write me where should i change :
------------------------------------------------------------------------------------Raycasting functions 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("Humanoid")~=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 function onKeyDown(key,mouse) key=key:lower() --[[if key=="r" and not reloading then reload(mouse) end]] end function movecframe(p,pos) p.Parent=game.Lighting p.Position=pos p.Parent=game.Workspace end function checkAllyWIJ(killer, victim) if game:findFirstChild("Teams")~=nil then if killer ~= victim then if killer.TeamColor==BrickColor.new("Bright blue") and victim.TeamColor==BrickColor.new("Bright green") then return true elseif killer.TeamColor==BrickColor.new("Bright green") and victim.TeamColor==BrickColor.new("Bright blue") then return true elseif killer.TeamColor == victim.TeamColor then return true else return false end return false else return true end return false else return false end end function takeDamage(dm, pl) if pl:findFirstChild("Shield")~=nil then sh=pl:findFirstChild("Shield") if sh.Value==0 then pl.Humanoid:TakeDamage(dm) elseif sh.Value<dm then newdm=dm-sh.Value sh.Value=0 pl.Humanoid:TakeDamage(newdm) elseif sh.Value>dm then sh.Value=sh.Value-dm elseif sh.Value==dm then sh.Value=0 end else pl.Humanoid:TakeDamage(dm) end end function fire(aim) script.Parent.Handle.Fire.Pitch=(math.random(-5,-1)/10)+1 sp.Handle.Fire:Play() local bullet=Bullet:clone() --[[local bt2=game.Lighting.BulletTexture:clone() bt2.BrickColor=BrickColor.new("Bright red") bt2.Mesh.Scale=Vector3.new(.5,.5,2)]]-- local totalDist=0 Lengthdist=-RayLength/.5 local startpoint=sp.Handle.CFrame*BarrlePos local direction=(aim-startpoint) local cfrm=CFrame.new(startpoint, direction+startpoint) local vector=startpoint+(direction.Unit*999) if (startpoint-vector).magnitude<1000 then if game.Workspace:FindPartOnRay(Ray.new(player.Character.Head.Position,startpoint-player.Character.Head.Position),player.Character)==nil then local hit,pos=raycast(startpoint,vector,player.Character) bullet.Parent=game.Workspace --bt2.Parent=game.Workspace if hit~=nil then if hit.Parent:FindFirstChild("VecHealth")~=nil then vech=hit.Parent:FindFirstChild("VecHealth") vech.Value=vech.Value-VehicleDamage end if hit.Parent:FindFirstChild("HealthStatus")~=nil then fo=hit.Parent:FindFirstChild("HealthStatus") fo.Value=fo.Value-BaseDamage end local humanoid=hit.Parent:FindFirstChild("Humanoid") if humanoid~=nil then local damage=math.random(BaseDamage-(BaseDamage*.25),BaseDamage+(BaseDamage*.25)) if hit.Name=="Head" then damage=damage*1.25 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 (checkAllyWIJ(plr, eplr)==false) then if hit.Parent:findFirstChild("ForceField")==nil then tagHumanoid(humanoid) takeDamage(damage, humanoid.Parent) sX=sfx:clone() sX.Parent=player sX:play() end end else if hit.Parent:findFirstChild("ForceField")==nil then tagHumanoid(humanoid) takeDamage(damage, humanoid.Parent) sX=sfx:clone() sX.Parent=player sX:play() end end end end distance=(startpoint-pos).magnitude bullet.CFrame=cfrm*CFrame.new(0,0,-distance/2) bullet.Mesh.Scale=Vector3.new(.15,.15,distance) else bullet.CFrame=cfrm*CFrame.new(0,0,-RayLength/2) bullet.Mesh.Scale=Vector3.new(.15,.15,RayLength) end if pos~=nil then --bt2.CFrame=bullet.CFrame --movecframe(bt2,pos) end local deb=game:FindFirstChild("Debris") if deb==nil then local debris=Instance.new("Debris") debris.Parent=game end check() game.Debris:AddItem(bullet,.05) game.Debris:AddItem(sX, .3) --game.Debris:AddItem(bt2,.5) end end end function onButton1Up(mouse) down=false end function onButton1Down(mouse) h=sp.Parent:FindFirstChild("Humanoid") if not enabled or reloading or down or h==nil then return end if Charge.Value<MaxCharge and h.Health>0 and overheated==false and battery==true then --[[if sp.Ammo.Value<=0 then if not reloading then reload(mouse) end return end]] down=true enabled=false while down do if Charge.Value>=MaxCharge or sp.Parent:FindFirstChild("Humanoid")==nil or overheated == true then break end sfd=sfd+1 if sfd>=shotsForDepl then sfd=0 batteryLife.Value=batteryLife.Value-math.random(minDepletion, maxDepletion) end if burst then local startpoint=sp.Handle.CFrame*BarrlePos local mag=(mouse.Hit.p-startpoint).magnitude local rndm=Vector3.new(math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag)) fire(mouse.Hit.p+rndm) Charge.Value=Charge.Value+math.random(chargeperfireMIN, chargeperfireMAX) if Charge.Value>=MaxCharge then break end wait(.05) local startpoint=sp.Handle.CFrame*BarrlePos local mag2=((mouse.Hit.p+rndm)-startpoint).magnitude local rndm2=Vector3.new(math.random(-(.1/10)*mag2,(.1/10)*mag2),math.random(-(.1/10)*mag2,(.1/10)*mag2),math.random(-(.1/10)*mag2,(.1/10)*mag2)) fire(mouse.Hit.p+rndm+rndm2) Charge.Value=Charge.Value+math.random(chargeperfireMIN, chargeperfireMAX) if Charge.Value>=MaxCharge then break end wait(.05) fire(mouse.Hit.p+rndm+rndm2+rndm2) Charge.Value=Charge.Value+math.random(chargeperfireMIN, chargeperfireMAX) elseif shot then Charge.Value=Charge.Value+math.random(chargeperfireMIN, chargeperfireMAX) local startpoint=sp.Handle.CFrame*BarrlePos local mag=(mouse.Hit.p-startpoint).magnitude local rndm=Vector3.new(math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag)) fire(mouse.Hit.p+rndm) local mag2=((mouse.Hit.p+rndm)-startpoint).magnitude local rndm2=Vector3.new(math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2)) fire(mouse.Hit.p+rndm+rndm2) local rndm3=Vector3.new(math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2)) fire(mouse.Hit.p+rndm+rndm3) local rndm4=Vector3.new(math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2)) fire(mouse.Hit.p+rndm+rndm4) else Charge.Value=Charge.Value+math.random(chargeperfireMIN, chargeperfireMAX) local startpoint=sp.Handle.CFrame*BarrlePos local mag=(mouse.Hit.p-startpoint).magnitude local rndm=Vector3.new(math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag)) fire(mouse.Hit.p+rndm) end wait(Firerate) if not automatic or battery==false then break end if down==true then wait(.06) end end enabled=true else sp.Handle.Trigger:Play() end end function onEquippedLocal(mouse) if mouse==nil then print("Mouse not found") return end script.GunGui:clone().Parent=player.PlayerGui mouse.Icon=Cursors[1] mouse.KeyDown:connect(function(key) onKeyDown(key,mouse) end) mouse.Button1Down:connect(function() onButton1Down(mouse) end) mouse.Button1Up:connect(function() onButton1Up(mouse) end) equiped=true down=false check() end function onUnequippedLocal(mouse) if player.PlayerGui:FindFirstChild("GunGui")~=nil then player.PlayerGui:FindFirstChild("GunGui").Parent=nil end equiped=false reloading=false down=false sp.Name = OriginalToolName end sp.Equipped:connect(onEquippedLocal) sp.Unequipped:connect(onUnequippedLocal) check()