In a LocalScript in my gun. The only problem is, when a bullet hits something with a humanoid, it does not take any damage at all. I would like for it to do so though.
Player = game.Players.LocalPlayer Character = Player.Character Gun = script.Parent Mouse = Player:GetMouse() --<< Changeable Values >>-- Gun_Speed = 2000 --The higher, the faster. Gun_Distance = 7000 --The higher, the longer distance it goes. TakeAway_Health = 10 Gun.Equipped:connect(function() Mouse.Icon = "http://www.roblox.com/asset/?id=43910485" local function PullTrigger() local Bullet = Instance.new("Part", game.Workspace) Bullet.CanCollide = false Bullet.Name = Player.Name Bullet.Size = Vector3.new(0.3,0.3,0.3) Bullet.Shape = "Ball" Bullet.BrickColor = BrickColor.new("White") Bullet.TopSurface = "Smooth" Bullet.BottomSurface = "Smooth" Bullet.Touched:connect(function(Hit) --PROBLEM IS HERE! if Hit.Parent:FindFirstChild("Humanoid") == nil and Hit.Parent.Name == script.Parent.Name then for i = 1,100 do Hit.Parent.Humanoid.Health = Hit.Parent.Humanoid.Health - TakeAway_Health end end end) Bullet.CFrame = Gun.Handle.CFrame Bullet.CFrame = CFrame.new(Bullet.Position, Mouse.Hit.p) Bullet:BreakJoints() local Power = Instance.new("BodyVelocity", Bullet) Power.Velocity = Bullet.CFrame.lookVector * Gun_Speed --Bullet Speed Power.MaxForce = Vector3.new(Gun_Distance,Gun_Distance,Gun_Distance) --How long it travels end Gun.Activated:connect(PullTrigger) end)
It should be ~= not ==