#stop player if they get too close to a wall while they dash

8 messages · Page 1 of 1 (latest)

strong thistle
#

i want to do this because if they hit the wall they just get flung

unreal karma
#

Which you are already doing.

strong thistle
#

that aint the issue

unreal karma
#
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

strong thistle
#

i want to check it during the wait

#

llet me see