Part not being properly created whilst freefalling

In order to recreate the jump-attack from the Sonic franchise (preferably the Classic era), I had thought of creating a Hitbox part whilst the player is an aerial state. Here’s some semi-pseudocode to get an idea of my original thought process. whilst programming.

Humanoid.FreeFalling:Connect(function(ACTIVE)
	if ACTIVE then
		local PART = Instance.new("Part")
		PART.Touched:Connect(function(HIT)
			if HIT.Parent:FindFirstChild("Humanoid") then
				local EM_HUMANOID = HIT.Parent.Humanoid
				EM_HUMANOID:TakeDamage(100)
			end
		end)
	else
		PART:Destroy()
	end
end)

I’m not sure if I can really explain what the issue is since even I am confused by the footage. It seems that whilst freefalling, the player gets anchored for a bit and then teleports back to the baseplate.


Here is a file of the current workspace…
Jump_Attack.rbxl (101.0 KB)

Have you tried setting up print statements to see if your code is running?

1 Like

You need to parent any newly created parts to something, in this case workspace ( or some descendant of workspace).

You’ll also need to weld it / anchor it / move it about and stuff in order to get it to be where you want

The Hitbox Part is parented to something

			if ACTIVE then
				local HITBOX_PART			= Instance.new("Part")
				HITBOX_PART.Color			= Color3.new(1, 0, 0)
				HITBOX_PART.Transparency	= 0.5
				HITBOX_PART.Name			= "Hitbox"
				HITBOX_PART.Parent			= CHARACTER
				HITBOX_PART.Size			= Vector3.new(6, 7, 5)
				HITBOX_PART.Position		= HUMANOIDROOTPART.Position
				HITBOX_PART.CanCollide		= false
				HITBOX_PART.Anchored		= true

				local HITBOX_WELD			= Instance.new("ManualWeld")
				HITBOX_WELD.Part0			= HITBOX_PART
				HITBOX_WELD.Part1			= HUMANOIDROOTPART
				HITBOX_WELD.C0				= HITBOX_WELD.Part0.CFrame:ToObjectSpace(HITBOX_WELD.Part1.CFrame)
				HITBOX_WELD.Parent			= HITBOX_WELD.Part0
				print("Active")
			else
				if CHARACTER:FindFirstChild("Hitbox") then
					local HITBOX_PART		= CHARACTER.Hitbox
					HITBOX_PART:Destroy()
				end
			end
1 Like

Okay, I believe that I’ve managed to resolve this. It could be that HITBOX_PART’s size is too large.

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