Hi,
I have tried to make a dash system by using BodyVelocity but I have a problem at if it hit something (like player dash and hit part), the player will just got knocked away, so did there is the better way to do the dash system?
This is code in server side:
Remote = game.ReplicatedStorage.DashEvent
Remote.OnServerInvoke = function(Player)
if game.ReplicatedStorage.Stamina:FindFirstChild(Player.Name) then
if game.ReplicatedStorage.Stamina[Player.Name].Current.Value >= 30 and Player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Swimming and Player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Seated and Player.Character.Humanoid.MoveDirection ~= Vector3.new(0,0,0) then
delay(0.1,function()
local attachment = Instance.new("Attachment",Player.Character.HumanoidRootPart)
local attachment1 = Instance.new("Attachment",Player.Character.Head)
local t1= Instance.new("Trail")
t1.Parent = Player.Character.HumanoidRootPart
t1.Attachment0 = attachment
t1.Attachment1 = attachment1
t1.Lifetime = .5
game.ReplicatedStorage.Stamina[Player.Name].Current.Value = game.ReplicatedStorage.Stamina[Player.Name].Current.Value - 30
local BV = Instance.new("BodyVelocity", Player.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = Player.Character.Humanoid.MoveDirection*100 -- This is how fast you will go in the air
game.Debris:AddItem(BV, 0.1)
wait(.3)
t1.Enabled =false
wait(.4)
game.Debris:AddItem(attachment,.1)
game.Debris:AddItem(attachment1,.1)
game.Debris:AddItem(t1,.1)
-- this one deletes the velocity so you stop flying up
--[[
local Clone = game.Lighting.DashEffect:Clone()
Clone.Parent = workspace
Clone.CFrame = Player.Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-1)
i = Player.Character.Head.Orientation.Y
Clone.Orientation = Vector3.new(90,i,0)
]]
-- local Clone = game.Lighting.DashEffect2:Clone()
-- Clone.Parent = workspace
-- Clone.CFrame = Player.Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-3)
-- i = Player.Character.Head.Orientation.Y
-- Clone.Orientation = Vector3.new(90,i,0)
end)
return true
else
return nil
end
else return nil
end
end
Thanks and sorry for bad English.