Can someone help with my hitbox script

My hitbox is in the wrong position I just want to know how I can fix it

Client Side:

local anim = script.Animation
local plr = game.Players.LocalPlayer
local Char  = plr.Character or plr.CharacterAdded:Wait()
local hum = Char:WaitForChild("Humanoid")
local Track = hum:LoadAnimation(anim)
local UIS = game:GetService("UserInputService")
local PunchEvent = game.ReplicatedStorage.PunchEvent
local db = false



UIS.InputBegan:Connect(function(input,proc)
	if proc then
		return
	end
	
	if input.UserInputType == Enum.UserInputType.MouseButton1 and not db then
		db = true
		PunchEvent:FireServer()
		Track:Play()
		wait(1)
		db = false
		
		
	end

end)

Server Side:

game.ReplicatedStorage.PunchEvent.OnServerEvent:Connect(function(plr)
	local char = plr.Character or plr.CharacterAdded:Wait()
	local HRP = char:WaitForChild("HumanoidRootPart")
	local Hitbox = Instance.new("Part")
    	


	Hitbox.Parent = game.ReplicatedStorage
	local HitboxClone = Hitbox:Clone()
	HitboxClone.Parent = workspace
	HitboxClone.Size = Vector3.new(4.1, 3.98, 2.78)
	HitboxClone.Position = HRP.CFrame.Position + Vector3.new(5,0,0)
	HitboxClone.Transparency = 0.5
	HitboxClone.Color = Color3.new(1,0,0)
	HitboxClone.Anchored = true
	HitboxClone.CanCollide = false
	wait(0.5)
	HitboxClone:Destroy()
	
	
end)

image

Im assuming you want it in front of the player, is so, change this:

HitboxClone.Position = HRP.CFrame.Position + Vector3.new(5,0,0)

to this

HitboxClone.CFrame = HRP.CFrame * CFrame.new(5,0,0)

Please specify next time what you want your code to do

1 Like

Thanks could you find help me find a way to make this script damage people who touch the hitbox

1 Like

I’ll just point you to your next goal, as I don’t really know how to use this thing myself

You should use workspace:GetPartBoundsInBox() what this thing basically does is get whatever part is inside a box,

Best video I could find in the span of 5 minutes:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.