It's a local script inside a tool (the tool has a handle also), inside the starterpack. I made it so that if you shot someone's torso or head it would do 50 damage, and if you shot someone's legs or arms it would do 25 damage. I tested it on dummies containing humanoids that have 100 health, and my gun would always do 50 damage. Whether I shot the head, torso, arms, legs, it would always do 50 damage, no matter what! So what did I do wrong here, and how do I fix it? This is the script:
local tool = script.Parent local player = game:GetService("Players").LocalPlayer tool.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 50) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) local beam = Instance.new("Part", workspace) beam.BrickColor = BrickColor.new("Black") beam.FormFactor = "Custom" beam.Material = "SmoothPlastic" beam.Transparency = 0.25 beam.Anchored = true beam.Locked = true beam.CanCollide = false local distance = (tool.Handle.CFrame.p - position).magnitude beam.Size = Vector3.new(0.3, 0.3, distance) beam.CFrame = CFrame.new(tool.Handle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2) game:GetService("Debris"):AddItem(beam, 0.1) if part then local humanoid = part.Parent:FindFirstChild("Humanoid") if not humanoid then humanoid = part.Parent.Parent:FindFirstChild("Humanoid") end if humanoid.Torso or humanoid.Head then humanoid:TakeDamage(50) elseif humanoid.RightArm or humanoid.LeftArm or humanoid.RightLeg or humanoid.LeftLeg then humanoid:TakeDamage(25) end end end) end)
The character's limbs do not reside in the Humanoid, they are directly in the Character model.
Also, you have to actually compare 'part' to the limbs, otherwise you're just checking if those limbs exist or not.
local tor,head = part.Parent.Torso,part.Parent.Head; local rarm,larm = part.Parent.RightArm,part.Parent.LeftArm; local rleg,lleg = part.Parent.RightLeg,part.Parent.LeftLeg; if part == tor or part == head then humanoid:TakeDamage(50) elseif part == rarm or part == larm or part == rleg or part == lleg then humanoid:TakeDamage(25) end