How Would I go about Making the Part Be on the floor no matter if im jumping or not?

Im trying to make a GroundPunch Abbility With a crack in the floor, however , If i jump It still Is going to the same Position as if im not jumping meaning it will be in the air. How can i fix this?

local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")

local Plr = game.Players.LocalPlayer
repeat task.wait() until Plr.Character
local char = Plr.Character or Plr.CharacterAdded:Wait()
local Humanoid = char:WaitForChild("Humanoid")
local HRP = char:WaitForChild("HumanoidRootPart")

local damage = 30

local Fists = script.Parent.Parent

local Swing = script:WaitForChild("Swing")

local CD = false
local Debounce = false
local PunchLanded = false
local FistsEquipped = false

local GroundPunch = script:WaitForChild("GroundPunch")
local GroundPunchTrack = Humanoid:LoadAnimation(GroundPunch)



Fists.Equipped:Connect(function()
	FistsEquipped = true
	Fists.Unequipped:Wait()
	FistsEquipped = false
end)

UIS.InputBegan:Connect(function(input)
	if FistsEquipped then
		if input.KeyCode == Enum.KeyCode.E then
			if not CD then
				PunchLanded = true
			GroundPunchTrack:Play()
			wait(0.15)
			Swing:Play()
			wait(0.25)
			local FloorCracksClone = RS.FloorCracks:Clone()
			FloorCracksClone.CFrame = HRP.CFrame * CFrame.new(0,-3,0)
			FloorCracksClone.Parent = workspace
			wait(2.5)
			FloorCracksClone:Destroy()
			PunchLanded = false
			end
		end
	end
end)



UIS.InputBegan:Connect(function(input)
	wait(0.25)
	if input.KeyCode == Enum.KeyCode.E then
		if PunchLanded == true then
			if not CD then
			CD = true
				local Event = nil 
				local Hitbox = RS.GroundPunchHB:Clone()
				Hitbox.CFrame = HRP.CFrame * CFrame.new(0,-3,0)
				Hitbox.Parent = workspace

				Event = Hitbox.Touched:Connect(function(hit)
					local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
				if hum and hum.Parent.Name ~= Plr.Name then
					if not Debounce then
						Debounce = true
							local Indicator = RS:WaitForChild("DmgIndicator")
							if Indicator then
								if PunchLanded == true then
								wait(0.1)
								local gui = Indicator:Clone()
								gui.Parent = hit.Parent.HumanoidRootPart
								gui.Shadow.Text = "-"..tostring(damage)
								gui.Shadow.Damage.Text = "-"..tostring(damage)
								gui.StudsOffset = Vector3.new(math.random(-2,2), math.random(-2,2), math.random(-2,2))
								local TweenDamageGui = game:GetService("TweenService"):Create(gui, TweenInfo.new(1, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 0, false), {Size = UDim2.new(1.5, 0 , 1.5 , 0)})
								TweenDamageGui:Play()
								game.Debris:AddItem(gui, 1.5)
								wait(0.1)
							    hum:TakeDamage(damage)
							    wait(0.3)
							    Debounce = false
								  end
							   end
						   end
						end
			        end)
			local weld = Instance.new("ManualWeld")
			weld.Part0 = Hitbox
			weld.Part1 = HRP
			weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
			weld.Parent = weld.Part0
			wait(0.1)
			Event = nil
			Hitbox:Destroy()
			wait(3)
			CD = false
			end
		end
	end
end)

Thats what happens when i jump and Click.

Anyone? I’m still struggling at this lmao.

You could try shooting a ray down from the character position. This ray will tell you where the ground is relative to the player, providing information as to where you should locate the crack. Using RayResult’s Position property should do the trick.

If you’re unfamiliar with raycasting, check this article out:

One problem, however, is that if the character is near a cliff, for example, the crack will appear over the edge of the cliff, still in the air. I don’t know how you plan to combat this, but it is just something I think you should be aware of. Note that this would be the case whether you implement a raycast system or not.

1 Like

If you need further help putting raycast into practice, let me know! :slightly_smiling_face:

1 Like

Don’t understand where the problem is. In your screenshot it looks working?

/!\ OFF-TOPIC /!\

What mean

?

1 Like

When he jumps, when the decal part is created, it is in the air, he wants the decal to be always placed onto the floor below him, not in the air when he jumps. Which he can use ray service like @xendatro suggested.

1 Like

Oh ok. Thanks for explaining @Entildo !

2 Likes

Sorry Guys I was afk Eating I’m gonna have a look and try what you’ve said. Thanks

How Would I Clone The part where the ray hits?

To anwser what lmao means it means laughing My a$$ off i’m not sure if your allowed to say that here tbh

Yooooo I got it working Thanks so much.

To anyone needing help with the same issue watch

1 Like

Try to look into raycasting. Just raycast a couple studs down from the HumanoidRootPart and filter the character out of the result. Then put the position of the crack on the position of the RaycastResult instead of on the position of the HumanoidRootPart.

1 Like

That’s why I said

And my post isn’t full of off topic content,

Also to make this post not full of off-topic content, I just say a in-topic thing:

This ground punch ability is a very good idea !! (It’s for adding a in-topic thing to my post but it still true.)

Ooh cool! I’m happy for you! Have a very good day!

1 Like