Need Help with Dash Script (how do i get floor part)

[pls See Edits]
yo so i am making a character movement system for my fps game input,etc. is working perfectly only problem is it keeps flinging my character on collision/impact with another object and i cant have tht in a fps heres the code-

local movement = {
	Forward = function(plr)
		print(plr.Character:GetAttribute("Mobility"))
		local hrp = plr.Character.HumanoidRootPart
		local bv = Instance.new("BodyVelocity")
		bv.Parent = hrp
		bv.MaxForce = Vector3.new(math.huge,0,math.huge)
		bv.Velocity = hrp.CFrame.LookVector *50
		bv.P = (100/plr.Character:GetAttribute("Mobility"))
	   deb:AddItem(bv,0.5)
	end,
	Backward = function(plr)
		print(plr.Character:GetAttribute("Mobility"))
		local hrp = plr.Character.HumanoidRootPart
		local bv = Instance.new("BodyVelocity")
		bv.Parent = hrp
		bv.MaxForce = Vector3.new(math.huge,0,math.huge)
		bv.Velocity = hrp.CFrame.LookVector *-50
		bv.P = (100/plr.Character:GetAttribute("Mobility"))
		deb:AddItem(bv,0.5)
	end,
	Left = function(plr)
		print(plr.Character:GetAttribute("Mobility"))
		local hrp = plr.Character.HumanoidRootPart
		local bv = Instance.new("BodyVelocity")
		bv.Parent = hrp
		bv.MaxForce = Vector3.new(math.huge,0,math.huge)
		bv.Velocity = hrp.CFrame.RightVector *-50
		bv.P = (100/plr.Character:GetAttribute("Mobility"))
		deb:AddItem(bv,0.5)
	end,
      Right = function(plr)
		print(plr.Character:GetAttribute("Mobility"))
		local hrp = plr.Character.HumanoidRootPart
		local bv = Instance.new("BodyVelocity")
		bv.Parent = hrp
		bv.MaxForce = Vector3.new(math.huge,0,math.huge)
		bv.Velocity = hrp.CFrame.RightVector *50
		bv.P = (100/plr.Character:GetAttribute("Mobility"))
		deb:AddItem(bv,0.5)
	end,
	Upward = function(plr)
		print(plr.Character:GetAttribute("Mobility"))
		local hrp = plr.Character.HumanoidRootPart
		local bv = Instance.new("BodyVelocity")
		bv.Parent = hrp
		bv.MaxForce = Vector3.new(0,math.huge,0)
		bv.Velocity = hrp.CFrame.UpVector *50
		bv.P = (plr.Character:GetAttribute("Mobility"))
		deb:AddItem(bv,0.5)
	end,
}

how do i stop the flinging??
edit: feel free to suggest advanced methods for this

edit:

so for this how do i get the floor ik tht the humanoid has a property for floormaterial but how do i get the floor object

so on another platform someone suggested me to make a region3 around the player and destroy bodyvelocity whn it touches smthg(other than the floor)

don’t use math.huge in the MaxForce, try just using a number like 10000+ and raycast in the direction the player is going in and if they run into a part, destroy the bodyvelocity

2 Likes

also if you wanna get the floor part you could raycast downwards the player and get RaycastResult.Instance

local FloorPart
local RaycastResult = workspace:Raycast(rootpart.Position,rootpart.CFrame.UpVector * -50) 
if RaycastResult then
      FloorPart = RaycastResult.Instance
end
1 Like

how do i get mutiple results from this raycast cuz the floor of mine has multiple parts

You could raycast it per render stepped probably.

1 Like

Maybe try region3 or try the reply above mine

1 Like

There is no need to destroy the bodyvelocity on impact. You just need to set the bodyvelocity.MaxForce to anything in between 100000 and 500000.
To prevent the character from flinging completely, you have to disable these specific humanoid states. Make sure you do this on the client.

Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
2 Likes