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:

01local char = game:GetService("Players").LocalPlayer.Character or game:GetService("Players").LocalPlayer.CharacterAdded:Wait()
02        local lowerTorso, rootPart = char:WaitForChild("LowerTorso"), char:WaitForChild("HumanoidRootPart")
03 
04    local params = RaycastParams.new()
05    params.FilterDescendantsInstances = {char}
06    params.FilterType = Enum.RaycastFilterType.Blacklist
07 
08    game:GetService("RunService").Heartbeat:Connect(function()
09        local ray = workspace:Raycast(rootPart.Position, Vector3.new(0, -char.Humanoid.HipHeight - 2, 0), params)
10        if ray then
11            local vector = rootPart.CFrame:VectorToObjectSpace(ray.Normal)
12            lowerTorso.Root.C0 = CFrame.new(0,-1,0,1,0,0,0,1,0,0,0,1) * CFrame.Angles(vector.z, 0, -vector.x)
13        end
14    end)

Answer this question