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:
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)
task.wait(0.5)
d = false
end
end)
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)
task.wait(0.2)
bv:Destroy()
task.wait(0.5)
d = false
end
end)
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.
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)
game:GetService("Debris"):AddItem(bv, 0.2)
task.wait(0.7)
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.
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
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)
task.wait(0.1)
bv:Destroy()
d = false
end
end)
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)
task.wait(0.02)
bv:Destroy()
d = false
end
end)
just converted to a supported format
the quality turned twice as bad when it was already bad:/
so basically,((script.Parent.Position - character.LowerTorso.Position).Unit*-50)Vector3.new(1,0,1)detects which side the player is on and cancels the Y position of BV so the player will not get flung into the air but the player gets pushed of the side that he is on. if you change -50 in the the .unit-50 to a positive number the player would get sucked in instead. when this is reversed, the player gets pushed out in the opposite direction.