Hey Guys! I’ve been needing to ask a question for myself and some other people. I’m a beginner scripter that needs help with the ‘Humanoid’ part. I simply need to know how to get ‘Humanoid’ as a variable from a script.
My script is located in the WorkSpace area so It’s not in the players part.
Any help is greatly appreciated as I’ve looked over YouTube and the Roblox Developer website but cannot find anything to do with my exact topic. Thanks
It would be nice to have a bit of context, like what you plan on doing with the humanoid. You can get the humanoid of players who joined the game by doing this in the script:
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
-- Do whatever you want to the humanoid here!
end)
end)
local part = script.Parent
local deb = false
part.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if deb or not hum then return end
deb = true
print(hum.Health)
wait(5)
deb = false
end)
local part = script.Parent
local deb = false
part.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if deb or not hum then return end
deb = true
part.Transparency = 1 --CHANGE THIS
end)