How would i make a body part receive damage when you click on a certain part

Title kinda says it all, i need some advice/support on how i would go onto making a certain part(s) do damage to your individual limbs.

i haven’t necessarily started the process of scripting this because I’m at quite a loss.
(edit) i have an understanding that the process of it has to contain limb values which i already have done

if any of you are confused on what i mean by parts ill include a screenshot giving a somewhat understanding, i just need a start to be honest im somewhat new to lua and im still learning so any feedback really helps a lot, ty.

When you click on the part, you would need a function to grab all your Limb’s health values in an array type fashion and then reduce the health of a random one

You could use something like this,

local ClickDetector = script.Parent
 
local function onClicked(Player)
	Player.Character.Humanoid:TakeDamage(5)
end

ClickDetector.MouseClick:Connect(onClicked)

:TakeDamage(), ClickDetector.

OP is asking for damage to individual limb’s but this one is a general click to lose health in humanoid script

You’re probably looking for something like this:

local interface; -- Path to the Interface where the player can select the limbs

for _, Limb in pairs(Interface:GetChildren()) do
    Limb.ClickDetector.MouseClick:Connect(function(player)
       player.Character[Limb.Name]:Destroy() -- Assuming each body part has a humanoid inside it, use :TakeDamage()
    end)
end

Do note, that the parts’ names inside the interface have to match those inside of the player.

1 Like

thanks dude this is going to help me a lot :smiley:

1 Like