Hello, recently I have been trying to make a dodge script for a personal project of mine. I’ve been using vectorforce and it has been going well except that when applying a force while a player is jumping makes them zoom across the map because there is no friction.
I tried applying 0 friction to players when they dodge and it works, but now whenever the player is midair they will be forced into the ground
ServerScript
(the local script is just a remote being fired from the client.)
function Dodge(Player, CombatType)
local Character = Player.Character or Player.CharacterAdded:wait(1)
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
local CombatTags = Humanoid:FindFirstChild("Combat")
local DodgeCooldown = CombatTags.DodgeCooldown
if DodgeCooldown.Value == true then return end
DodgeCooldown.Value = true
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local function AddFriction()
local Friction = PhysicalProperties.new(1,1,1,1,1)
for i, v in pairs(Character:GetChildren()) do
if v:IsA("Part") then v.CustomPhysicalProperties = Friction end
end
end
local function RemoveFriction()
local Friction = PhysicalProperties.new(0,0,0,0,0)
for i, v in pairs(Character:GetChildren()) do
if v:IsA("Part") then v.CustomPhysicalProperties = Friction end
end
end
local function CreateVelocity(Velocity)
local Attatchment = Instance.new("Attachment")
Attatchment.Parent = HumanoidRootPart
local VectorForce = Instance.new("VectorForce")
VectorForce.Parent = Attatchment
VectorForce.ApplyAtCenterOfMass = true
VectorForce.Attachment0 = Attatchment
VectorForce.Force = Velocity
RemoveFriction()
Debris:AddItem(Attatchment, .2)
Debris:AddItem(VectorForce, .2)
task.wait(.1)
AddFriction()
DodgeCooldown.Value = false
end
if CombatType == "ForwardDodge" then
local Velocity = Vector3.new(0,0,-100)
CreateVelocity(Velocity)
return
end
if CombatType == "RightDodge" then
return
end
if CombatType == "LeftDodge" then
return
end
if CombatType == "BackwardsDodge" then
return
end
end
end
any help would be greatly appreciated.