Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

FindFirstChild Hitbox not working?

Asked by
14jojo -19
1 year ago
local Hitboxes = {'Head', 'Torso', 'LeftUpperArm', 'RightUpperArm', 'LeftLowerLeg', 'RightLowerLeg'}


local hitbox = Hitboxes[math.random(1,#Hitboxes)]
print(hitbox) -- prints out hitbox

print(game.Players.LocalPlayer:FindFirstChild(hitbox)) -- prints out nil

1 answer

Log in to vote
0
Answered by 1 year ago

It is printing out nil because it is searching for a hitbox inside of the player, not the character. Change it to this:

local Hitboxes = {'Head', 'Torso', 'LeftUpperArm', 'RightUpperArm', 'LeftLowerLeg', 'RightLowerLeg'}


local hitbox = Hitboxes[math.random(1,#Hitboxes)]
print(hitbox) --prints out a hitbox

print(game.Players.LocalPlayer.Character:FindFirstChild(hitbox)) -- also prints out a hitbox
Ad

Answer this question