#stop player if they get too close to a wall while they dash
8 messages · Page 1 of 1 (latest)
You can try raycasting.
Which you are already doing.
that aint the issue
local replstor = game:GetService("ReplicatedStorage")
local revent = replstor.Dash
revent.OnServerEvent:Connect(function(plr)
local chr = plr.Character
local plrcframe = chr:GetPrimaryPartCFrame()
local targetPosition = plrcframe.Position + plrcframe.LookVector * 100
local bv = Instance.new("BodyVelocity")
bv.Velocity = plrcframe.LookVector * 100
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.Parent = plr.Character:WaitForChild("HumanoidRootPart") or plr.Character:WaitForChild("UpperTorso")
local checkInterval = 0.05
local maxDuration = 0.3
local startTime = tick()
while (tick() - startTime) < maxDuration do
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {chr}
local raycastResult = workspace:Raycast(plrcframe.Position, plrcframe.LookVector * 2, raycastParams)
if raycastResult then
bv:Destroy()
break
end
wait(checkInterval)
end
bv:Destroy()
end)
like that