How to get the Humanoid in a touch event

Описание к видео How to get the Humanoid in a touch event

Welcome to a Roblox Studio tutorial, Today is I’ll how to get the humanoid in a touch event in Roblox scripting!

Question/Challenge of the video:
no challenge but here’s the script :D

local part = script.Parent -- Replace with the part you want to detect touches on

part.Touched:Connect(function(hit)
-- Check if the part's parent has a humanoid
local character = hit.Parent

if character and character:FindFirstChild("Humanoid") then
local humanoid = character.Humanoid

print("Humanoid detected:", humanoid.Parent.Name)

-- Perform actions on the humanoid
humanoid:TakeDamage(10) -- Example: Deal 10 damage
end
end)

I edited this with InShot(it’s a really good app)


shout out to:    / @criticaljp  

@criticaljp

#roblox #robloxdev #scripting #variables #functions #TheDevKing
#AlvinBlox #games #game #gaming
#coding #WomenInCoding #Stem #scripts #smart

Комментарии

Информация по комментариям в разработке