How can i make a player slide off of a mob?

i want to make players slide off of my mobs especially if the mob is jumping because it carries the player upwards. how do i make it so that players slide off of the mobs? i dont really wanna change the maximum slope angle and ive tried using friction and frictionweight but you can still get carried up into the air because it dosent instantly slide.i want the player to just slide off quickly insted of getting carried into the air. also, if the player jumps on top of the mob then the player should slide off solwly. im currently using this but it dosent work

``````
local part = script.Parent

local density = 0
local friction = 0.001
local elasticity = 0
local frictionWeight = 80
local elasticityWeight = 0

local physProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
part.CustomPhysicalProperties = physProperties

``````

Apply some velocity to any players on top of the mob, don’t make it really high so the players don’t get yeeted
Edit: don’t use `part.Velocity`. Use this:

Put this in like the mob’s head.

``````local d = false
script.Parent.Touched:Connect(function(hit)
if not d and hit.Parent:FindFirstChild(“Humanoid”) and hit.Parent ~= script.Parent.Parent then
d = true
hit.Parent:SetPrimaryPartCFrame(hit.Parent.PrimaryPart.CFrame + Vector3.new(5,0,5)
d = false
end
end)
``````

It could be used to clip through thin walls and corners of walls

Fr. Lemme fix it real quick.

``````
local d = false
script.Parent.Touched:Connect(function(hit)
if not d and hit.Parent:FindFirstChild(“Humanoid”) and hit.Parent ~= script.Parent.Parent then
local bv = Instance.new(“BodyVelocity”)
bv.P = 2000
bv.MaxForce = Vector3.new(10000,10000,10000)
bv.Parent = hit
bv.Velocity = Vector3.new(10,1,5)
bv:Destroy()
d = false
end
end)
``````
1 Like

That code is gonna yeet the player upwards, also use `Debris`

Not by a lot. The velocity only lasts for .2 seconds and its velocity is (10,1,5)
I purposely made it go up a bit so it doesn’t drag the mob or anything btw
Also I’m typing this on a phone at 1:43 AM.
I don’t think I have the energy to add an extra two lines of code for debris lol. Just a minor performance thing if you add one bodyvelocity.

1 Like
``````
local d = false
script.Parent.Touched:Connect(function(hit)
if not d and hit.Parent:FindFirstChild(“Humanoid”) and hit.Parent ~= script.Parent.Parent then
local bv = Instance.new(“BodyVelocity”)
bv.P = 2000
bv.MaxForce = Vector3.new(10000,10000,10000)
bv.Parent = hit
bv.Velocity = Vector3.new(10,1,5)
d = false
end
end)

``````

Cool, you (took my script but we don’t talk about that and) just added one line for debris and that might be marked as solution.
I’m gonna go to bed now.

Good night or morning (or afternoon) depending what timezone you’re in.

edit: sheesh

1 Like

I use Ontario timezone 3 AM

1 Like

how can i detect how much the mob moves? i want to make the player slide slowly if the mob is slowly walking but if the mob jumps then the player should move faster.
edit: the player should also slide off like these examples cause that’s is more realistic

i might have a solution. the velocity can be used to squish the player so i can make like a invisible cone thingy on top of the mob’s head and squish the player to make the player slip. and maybe ill keep the 0 friction so the player slips faster
edit: it doesnt work

just noticed a problem: the player cant move and gets stuck when it touches the mob

another problem is that the player gets moved if the character touches the mob sideways.

Oh yeah, first of all, bodyvelocities force the player in one direction. Secondly, it activates on touch.
I suggest adding a tiny part on top of the mob’s head and weld it to the head. Less likely to get a random slide.

``````
local d = false
script.Parent.Touched:Connect(function(hit)
if not d and hit.Parent:FindFirstChild(“Humanoid”) and hit.Parent ~= script.Parent.Parent then
local bv = Instance.new(“BodyVelocity”)
bv.P = 2000
bv.MaxForce = Vector3.new(10000,10000,10000)
bv.Parent = hit
bv.Velocity = Vector3.new(15,1,15)
bv:Destroy()
d = false
end
end)
``````

Try this script.

how can i make the sliding realistic like in the pictures? kinda like how you slide off of mobs in the game vesteria

That would be a bit more difficult because you would need to to find which side of the mob the player is on to make the velocity slide the way.

Also sorry, I’ve never really played Vesteria before.

new script :

``````local d = false
script.Parent.Touched:Connect(function(hit)
local nearestPlayer, nearestDistance
local part = script.Parent.Parent.HumanoidRootPart
local maxDistance = 10000
local Players = game:GetService("Players")
if not d and hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= script.Parent.Parent then
for _, player in pairs(Players:GetPlayers()) do
local character = player.Character
local distance = player:DistanceFromCharacter(part.Position)
if not character or
distance > maxDistance or
(nearestDistance and distance >= nearestDistance)
then
continue
end
nearestDistance = distance
nearestPlayer = player
end
local character = nearestPlayer.Character
local bv = Instance.new("BodyVelocity")
bv.P = 2000
bv.MaxForce = Vector3.new(10000,10000,10000)
bv.Parent = hit
bv.Velocity = ((script.Parent.Position - character.LowerTorso.Position).Unit*-50)*Vector3.new(1,0,1)
bv:Destroy()
d = false
end
end)
``````

result when put into a block:
robloxapp-20221231-1828016.wmv (4.8 MB)
pretty good and realistic

Darn, it’s a file.
From what I’m reading from the script, it’s like if a player is within range once the part is touched, he gets pushed back?

just converted to a supported format