Cant Make A Character Lay On The Ground For GroundSlams

  1. I want this character/npc to lay on the ground when anchored

  2. no matter what what I do I cant get it to lay back down on the ground it always hovers in midair like its not being moved onto the floor

  3. I have tried to move it downwards by 1 as shown in my code example even tho the hitpos is already on the ground (I tested this with some visulization by spawning a part where the hitpos was) , I tried changing the hipheight by -2 or -3, I tried setting the humanoid to physics, I tried turning on PlatformStand but its always the same outcome of the npc hovering in mid air

function Daze.Dazeplr(Charactertobedazed: Model, duration: number, hitpos: Vector3)
	local Humanoid = Charactertobedazed:FindFirstChildOfClass("Humanoid")
	local HumanoidRootPart:BasePart = Charactertobedazed:FindFirstChild("HumanoidRootPart")
	
	Humanoid.AutoRotate = false
	Humanoid.PlatformStand = true
	Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
	Charactertobedazed:MoveTo(hitpos - Vector3.new(0, -3, 0))

	HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.CFrame.Position) * CFrame.Angles(math.rad(90),0,0)

	HumanoidRootPart.Anchored = true
end

function Daze.AttemptDaze(character, floorRange, duration)
	if not character then warn("pass a Character 1st") return end
	if not floorRange or floorRange <= 0 then warn("Pass A Range 2nd") return end
	if not duration then warn("pass a duration 3rd") return end

	local hrp = character:FindFirstChild("HumanoidRootPart")
	local hum = character:FindFirstChildOfClass("Humanoid")

	if not hrp or not hum then return end


	if StateMachine.GetState(character,"Daze") then
		return
	end

	local params = RaycastParams.new()
	params.FilterDescendantsInstances = {
		workspace.Fx,
		character,
		workspace.Live
	}
	params.FilterType = Enum.RaycastFilterType.Exclude

	local result = workspace:Raycast(
		hrp.Position,
		Vector3.new(0,-floorRange,0),
		params
	)

	if not result then return end

	local hitpos = result.Position
	Daze.Dazeplr(character,duration,hitpos)
	
end

– result of current code making them hover instead of lay on the ground (red is where they should be if it worked right)

maybe its better to do this with anims im not sure i just want something that makes the character lay on the ground and stand back up until the duration is over any help would be loved because I cant find anything on this topic

1 Like

MoveTo line is actually shoving it UP (hitpos - Vector3.new(0, -3, 0) = +3 on Y, lol). ditch MoveTo entirely and just set the CFrame.

but yeah animations are 100x cleaner and way easier to stand back up after duration. just load/play a simple lie-down anim (R15 has free ones in toolbox or make a quick one)