So I want to move the character to another side of the square to another, for example, this clip I found
https://gyazo.com/ecaff3fb9efaccaf4b6300c4bad51554 It’s gyazo ilk it’s not my clip.
script:
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local HRP = Char:WaitForChild("HumanoidRootPart")
local Hum = Char:WaitForChild("Humanoid")
local Head = Char:WaitForChild("Head")
local UIS = game:GetService("UserInputService")
local onwall = false
local prevwall
local controls = {up = 0, down = 0, left = 0, right = 0}
local lol = true
local changing = false
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space then
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {Head.Parent}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local RaycastResults = workspace:Raycast(Head.Position, Head.CFrame.LookVector * 2, raycastParams)
local RaycastResults2 = workspace:Raycast(Head.Position, Head.CFrame.RightVector * 2, raycastParams)
local RaycastResults3 = workspace:Raycast(Head.Position, -Head.CFrame.RightVector * 2, raycastParams)
if RaycastResults then
local hit = RaycastResults.Instance
local ORI = RaycastResults.Instance.Orientation
local pos = RaycastResults.Position
local Normal = RaycastResults.Normal
if hit then
prevwall = hit
print(hit)
print(Normal)
if onwall == false then
onwall = true
Hum.PlatformStand = true
local bodypos = Instance.new("BodyVelocity")
bodypos.Name = "ClimbVelocity"
bodypos.Velocity = Vector3.new(0,0,0)
bodypos.P = Vector3.new(100000,100000,100000)
bodypos.MaxForce = Vector3.new(10000,10000,10000)
bodypos.Parent = HRP
local bodygyro = Instance.new("BodyGyro", HRP)
bodygyro.D = 600
bodygyro.P = 100000
bodygyro.MaxTorque = Vector3.new(30000,30000,30000)
HRP.Velocity = Vector3.new(0,0,0)
HRP.CFrame = CFrame.new(HRP.CFrame.p,Vector3.new(HRP.Position.X - Normal.x,HRP.Position.Y,HRP.Position.Z - Normal.z))
bodygyro.CFrame = CFrame.new(HRP.CFrame.p,Vector3.new(HRP.Position.X - Normal.x,HRP.Position.Y,HRP.Position.Z - Normal.z))
Hum.AutoRotate = false
Hum.PlatformStand = true
if onwall == true then
wait(0.1)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,12,0)
controls[1] = 1
if controls[4] == -1 then
bodypos.Velocity = HRP.CFrame.RightVector * 12
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,12,0)
elseif controls[3] == 1 then
bodypos.Velocity = -HRP.CFrame.RightVector * 12
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,12,0)
end
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,-12,0)
bodypos.Velocity = Vector3.new(0,0,0)
controls[1] = 0
if controls[4] == -1 then
bodypos.Velocity = HRP.CFrame.RightVector * 12
elseif controls[3] == 1 then
bodypos.Velocity = -HRP.CFrame.RightVector * 12
end
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.S then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,-12,0)
controls[2] = -1
if controls[4] == -1 then
bodypos.Velocity = HRP.CFrame.RightVector * 12
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,-12,0)
elseif controls[3] == 1 then
bodypos.Velocity = -HRP.CFrame.RightVector * 12
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,-12,0)
end
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.S then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,12,0)
bodypos.Velocity = Vector3.new(0,0,0)
controls[2] = 0
if controls[4] == -1 then
bodypos.Velocity = HRP.CFrame.RightVector * 12
elseif controls[3] == 1 then
bodypos.Velocity = -HRP.CFrame.RightVector * 12
end
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.D then
bodypos.Velocity = HRP.CFrame.RightVector * 12
controls[4] = -1
if controls[1] == 1 then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,12,0)
elseif controls[2] == -1 then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,-12,0)
end
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.D then
bodypos.Velocity = -HRP.CFrame.RightVector * 0
controls[4] = 0
if controls[1] == 1 then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,12,0)
elseif controls[2] == -1 then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,-12,0)
end
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.A then
bodypos.Velocity = -HRP.CFrame.RightVector * 12
controls[3] = 1
if controls[1] == 1 then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,12,0)
elseif controls[2] == -1 then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,-12,0)
end
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.A then
bodypos.Velocity = HRP.CFrame.RightVector * 0
controls[3] = 0
if controls[1] == 1 then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,12,0)
elseif controls[2] == -1 then
bodypos.Velocity = bodypos.Velocity + Vector3.new(0,-12,0)
end
end
end)
end
end
end
spawn(function()
while true do
wait()
local RaycastResults = workspace:Raycast(Head.Position, Head.CFrame.LookVector * 2, raycastParams)
local RaycastResults2 = workspace:Raycast(Head.Position, Head.CFrame.RightVector * 2, raycastParams)
local RaycastResults3 = workspace:Raycast(Head.Position, -Head.CFrame.RightVector * 2, raycastParams)
if onwall == true then
if RaycastResults2 then
if changing == false then
changing = true
local hit = RaycastResults2.Instance
local pos = RaycastResults2.Position
local Normal = RaycastResults2.Normal
HRP.CFrame = CFrame.new(HRP.CFrame.p,Vector3.new(HRP.Position.X - Normal.x,HRP.Position.Y,HRP.Position.Z - Normal.z))
HRP.BodyGyro.CFrame = CFrame.new(HRP.CFrame.p,Vector3.new(HRP.Position.X - Normal.x,HRP.Position.Y,HRP.Position.Z - Normal.z))
if controls[4] == -1 then
HRP.ClimbVelocity.Velocity = HRP.CFrame.RightVector * 12
end
wait(0.7)
changing = false
end
end
if RaycastResults3 then
if changing == false then
changing = true
local hit3 = RaycastResults3.Instance
local pos3 = RaycastResults3.Position
local Normal3 = RaycastResults3.Normal
HRP.CFrame = CFrame.new(HRP.CFrame.p,Vector3.new(HRP.Position.X - Normal.x,HRP.Position.Y,HRP.Position.Z - Normal3.z))
HRP.BodyGyro.CFrame = CFrame.new(HRP.CFrame.p,Vector3.new(HRP.Position.X - Normal.x,HRP.Position.Y,HRP.Position.Z - Normal3.z))
if controls[3] == 1 then
HRP.ClimbVelocity.Velocity = -HRP.CFrame.RightVector * 12
end
wait(0.7)
changing = false
end
end
if RaycastResults == nil then
lol = true
end
end
end
end)
end
end
end)