This is the script I used for the rays of the gun.
plr = game.Players.LocalPlayer enabled = true down = false laser = false reloadtime = 3 waittime = 0.1 maxammo = 20 ammo = maxammo function Fire() if enabled then if ammo > 0 then enabled = false local p = Instance.new("Part",workspace) p.Name = "Bullet" p.BrickColor = plr.TeamColor p.CanCollide = false p.TopSurface = "Smooth" p.BottomSurface = "Smooth" p.FormFactor = "Custom" p.Size = Vector3.new(0.2,0.2,10) mouse = plr:GetMouse() local pos = script.Parent.Handle.Position local focus = mouse.Hit.p p.CFrame = CFrame.new(pos,focus) p.CFrame = p.CFrame+p.CFrame.lookVector*5 local v = Instance.new("BodyVelocity",p) v.maxForce = Vector3.new(4000,4000,4000) v.velocity = p.CFrame.lookVector*250 local s1 = script.Damage:clone() s1.Parent = p s1.Disabled = false ammo = ammo-1 script.Parent.Name = "Gun ("..ammo..")" wait(waittime) enabled = true end end end function Fire2() if enabled then if ammo > 0 then ammo = ammo-1 script.Parent.Name = "Gun ("..ammo..")" enabled = false mouse = plr:GetMouse() local ray = Ray.new(script.Parent.Handle.Position,(mouse.Hit.p-script.Parent.Handle.Position.unit*2000)) local hit,pos = workspace:FindFirstPartOnRay(ray,plr.Character) local hum = hit.Parent:findFirstChild("Humanoid") if hum ~= nil then hum:TakeDamage(10) end wait(waittime) enabled = true end end end script.Parent.Equipped:connect(function(m) m.KeyDown:connect(function(key) if key == "r" then if ammo == maxammo then enabled = false repeat ammo = ammo+1 wait(reloadtime/maxammo) script.Parent.Name = "Gun ("..ammo..")" until ammo == maxammo enabled = true end end end) m.Button1Down:connect(function() down = true end) m.Button1Up:connect(function() down = false end) end) script.Parent.Activated:connect(function() if not laser then Fire() else Fire2() end end)
Now, this script is under the rays script which has the error.
damage = 20 script.Parent.Touched:connect(function(hit) if hit.Parent.ClassName ~= "Tool" or hit.Parent.ClassName ~= "Hat" then if hit.Parent:findFirstChild("Humaniod") ~= nil then if hit.Player.Name == script.Player.Name then if hit.Name == "Head" then hit.Parent.Humaniod:TakeDamage(damage*1.5) else hit.Parent.Humaniod:TakeDamage(damage) end end end script.Parent:Destroy() end end)
My error for the script above(damage) is:
Touched is not a valid member of LocalScript
What did I do wrong?