Heya!
I was wondering for the past few days now of how to make a wall run script. All of my scripts don’t work . So, I tried searching something on Google. Still, nothing.
Here is my current code, but doesn’t work :
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
while char and wait() do
local hrp = char:WaitForChild("HumanoidRootPart")
local rightRay = workspace:Raycast(hrp.Position, hrp.CFrame.lookVector * 300)
local leftRay = workspace:Raycast(hrp.Position, -hrp.CFrame.lookVector * 300)
if not rightRay or not leftRay then return end
if rightRay.Instance then
print(rightRay.Instance.Name.." | "..tostring(rightRay.Instance.Position))
end
if leftRay.Instance then
print(leftRay.Instance.Name.." | "..tostring(leftRay.Instance.Position))
end
if rightRay.Instance and leftRay.Instance then
if hrp:FindFirstChildOfClass("BodyVelocity") then
hrp:FindFirstChildOfClass("BodyVelocity"):Destroy()
end
local rr_mag = (rightRay.Instance.Position - hrp.Position).magnitude
local lr_mag = (leftRay.Instance.Position - hrp.Position).magnitude
local min = math.min(rr_mag, lr_mag)
print(rightRay.Instance.Name, rightRay.Normal)
local chosenRay = nil
if min == rr_mag then chosenRay = rightRay else chosenRay = leftRay end
if chosenRay.Normal.Y ~= 0 then return end
local bv = Instance.new("BodyVelocity", hrp)
bv.MaxForce = Vector3.new('inf','inf','inf')
bv.Velocity = chosenRay.Normal:Cross(Vector3.new(0, 1, 0))
end
end
end)
end)
Thanks,
Dragon
p.s I don’t want something similar to EgoMoose’s gravity controller module