So I have a script that makes you dash forwards after double tapping W. Whenever I double tap W in front of a wall I will either go through it or my character will go flying across the map. I would just like to figure out how to make it so that doesn't happen anymore. Any help would be appreciated.
Local Script:
local player = game.Players.LocalPlayer
local character = player.Character
local hum = character:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local HRP = character:WaitForChild("HumanoidRootPart")
local W = 0
local FrontFlipping = tick() - W
local Ww = false
UIS.InputBegan:connect(function(input, event)
if Ww then return end
if input.KeyCode == Enum.KeyCode.W and not event then
FrontFlipping = tick() - W
if FrontFlipping < 0.2 then
Ww = true
local Table = {}
hum.WalkSpeed = 0
for i,v in pairs(character:GetChildren()) do
if v:IsA("Part") then
local BodyForce = Instance.new("BodyForce",v)
BodyForce.Force = Vector3.new(0,workspace.Gravity*v:GetMass(),0)
table.insert(Table, BodyForce)
end
end
for i = 1,16 do
for i,v in pairs(character:GetChildren()) do
if v:IsA("BasePart") then
v.Velocity = Vector3.new(0,0,0)
end
end
character:SetPrimaryPartCFrame(character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3))
wait(1/100)
end
for i,v in pairs(Table) do
v:Destroy()
end
hum.WalkSpeed = 16
W = 0
wait(0.25)
Ww = false
return
end
W = tick()
end
end)
Regular script that clones local script into player:
game.Players.PlayerAdded:connect(function(plr)
local A = script.Script:Clone()
A.Parent = plr.Character
plr.CharacterAdded:connect(function(char)
local A = script.Script:Clone()
A.Parent = char
end)
end)

3 comments
Short answer - http://wiki.roblox.com/index.php?title=API:Class/BodyForce
lol no
I'm wondering if raycasting would work for this