Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why my Wall Script not working?

Asked by 3 years ago
Edited 3 years ago

I want to allow Players to walk on the ramp. But they falldown if they stop walking. My Script is not working. I don't know why.

Here is my code:

local char = game:GetService("Players").LocalPlayer.Character or game:GetService("Players").LocalPlayer.CharacterAdded:Wait()
        local lowerTorso, rootPart = char:WaitForChild("LowerTorso"), char:WaitForChild("HumanoidRootPart")

    local params = RaycastParams.new()
    params.FilterDescendantsInstances = {char}
    params.FilterType = Enum.RaycastFilterType.Blacklist

    game:GetService("RunService").Heartbeat:Connect(function()
        local ray = workspace:Raycast(rootPart.Position, Vector3.new(0, -char.Humanoid.HipHeight - 2, 0), params)
        if ray then
            local vector = rootPart.CFrame:VectorToObjectSpace(ray.Normal)
            lowerTorso.Root.C0 = CFrame.new(0,-1,0,1,0,0,0,1,0,0,0,1) * CFrame.Angles(vector.z, 0, -vector.x)
        end
    end)

Answer this question