I’m trying to expand the player’s hitbox so it can hit more touch events.
I’ve tried messing around with humanoidrootpart but that causes issues with how the player moves.
I’ve tried adding an extra part into the player but it can’t hit touch events other than limbs & hrp from motor6d.
I can’t figure out how to find a solution or I’m just pretty dumb to see it.
If anyone could help me out, very much appreciated.
It’s a single-player game fyi.
You can create a part around the player and size it however you wish, then you weld it to HumanoidRootPart, and it should work fine. You can make an ignore list for the character parts.
I just made this script (you need to add it into StarterPlayerScripts) that should create a bigger hitbox for the player. I made this by loosely following what @TheRealANDRO suggested.
The part that work as a hitbox should be semitransparent but you can change it to fully transparent (line 12)
Feel free to adjust it based on your needs!
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
-- Sets a new hitbox size
local hitboxSize = Vector3.new(3, 7.5, 1.5) -- You can adjust this on your liking
-- Create a new hitbox part for interaction
local hitbox = Instance.new("Part")
hitbox.Size = hitboxSize
hitbox.CFrame = humanoidRootPart.CFrame -- Align with the HumanoidRootPart
hitbox.Transparency = 0.5 -- Set transparency to make it visible but you can turn it invisible by setting this to 0
hitbox.BrickColor = BrickColor.new("Bright blue") -- Choose a color for the hitbox
hitbox.Material = Enum.Material.Neon -- Make it visually distinct
hitbox.CanCollide = true -- Allow it to interact with the environment
hitbox.Anchored = false -- Ensure the hitbox can move
hitbox.Massless = true -- Make the hitbox not affect the player's weight or bigger it gets heavier it becomes
hitbox.Parent = character -- Parent it to the character
--hitbox.CanTouch = true
--hitbox.CanQuery = true
--hitbox.CanCollide = false
-- Weld the hitbox to the HumanoidRootPart so it moves with the player
local weld = Instance.new("WeldConstraint")
weld.Part0 = humanoidRootPart
weld.Part1 = hitbox
weld.Parent = humanoidRootPart
-- Detect touch events on the hitbox
local function onHitboxTouched(hit)
print("Hitbox was touched by:", hit.Name)
end
hitbox.Touched:Connect(onHitboxTouched) -- Connect the touch event to the function
Thank you for your time writing this, I only needed the existence of weld. I put it in use on the script storage service and it still works fine. One more thing, if you can, could you help me out with the cylinder as I mentioned above this comment?