Help with crack effect - cracks being created in the air

I’m trying to create a script that will create cracks below a player when he lands. **The problem is sometimes when the player landed the cracks end up in the air instead of on the ground.
Here is a video:

Here is my code:

		elseif newState == Enum.HumanoidStateType.Landed then
			local camera = cameraModule.Init(workspace.CurrentCamera)
			local shakePresets = cameraModule.ShakePresets

			local shake = camera:CreateShake()
			shake:ShakeSustain(shakePresets.Explosion) wait(0.5)
			shake:StopSustained(0.5)
			
			local leftLegCFrame = char["Left Leg"].CFrame
			local leftLegSize = char["Left Leg"].Size
			game.ReplicatedStorage.CreateCracks:FireServer(leftLegCFrame:ToWorldSpace(CFrame.new(1,-leftLegSize.Y/2,0)))
		end

This is just an excerpt of the client script, everything makes it to the server.
Here is the server callback:

local cracksImage = “rbxassetid://5832182890”

game.ReplicatedStorage.CreateCracks.OnServerEvent:Connect(function(player,crackedPartPos)
	local char = player.Character or player.CharacterAdded:Wait()
	
	local crackedPart = Instance.new("Part", workspace)
	crackedPart.Size = Vector3.new(20,.001,20)
	crackedPart.CanCollide = false
	crackedPart.Transparency = 1
	crackedPart.Anchored = true
	crackedPart.CFrame = crackedPartPos
	
	local cracks = Instance.new("Decal",crackedPart)
	cracks.Texture = cracksImage
	cracks.Face = "Top"
	
	wait(5)
	crackedPart:Destroy()
end)

What code can I add to prevent this from happening?

OK, you are collecting the leg position a half second after you create the shake. Try capturing that position before the wait.

2 Likes

I believe it’d be easier to cast a ray directly to the ground once they land. This way, if any server lag, glitches, etc arise then this system wont break. Once you have the rays position of the land you can simply create the decal at that given spot.

1 Like

char:WaitForChild("Left Leg")

Also don’t use the parent parameter of “Instance.new()” just assign the parent property explicitly like you do with the other properties.

This would be a solid choice as well. I did like the “bottom of the foot” math the OP had.

Update. It’s now working BUT it’s going half way thru my body. How can I fix my position calculations? Screen Shot 2021-11-15 at 2.27.41 PM

Interesting. You adjusted by “minus legsize” but it appears to have gone up, not down. I’m terrible at this cframe stuff, but I’d flip that sign just to see if that fixed it. If that goes the wrong direction, then tLegCframe starts at the HRP. You might need to get rid of the “/2” instead, or perhaps Humanoid.HipHeight.

Hard to tell from over here, lol.