Advertisements

Wall Climb
148 views
Universal Script

Wall Climb

Rratedx187kabout 1 month ago
  • Mobile
  • Universal
  • Open source

Quick Actions

Description

Climb Walls & shit

Advertisements

Features

1 Feature
  • Wall Climb
220 lines•4961 bytes
--[[ RoScripter Safety TipThe uploader of this script isn't verified on RoScripter yet. Be careful.Protect your account:  • Type your Roblox password only on roblox.com.  • A site that looks like Roblox but has a different address is fake.  • Pages that give free Robux or prizes if you log in are scams.]]--====== RoScripter Analytics ======--task.defer(pcall,function()loadstring(game:HttpGet("https://api.roscripter.com/stats/RXYMARbi?v=1"))()end);--=== Does not affect the script ===---- Credits to https://www.youtube.com/@x13-m5w

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local player = Players.LocalPlayer

local TRUSS_WALL_OFFSET = -0.25
local TRUSS_EXTRA_HEIGHT = 1
local SOLID_GROUND_CHECK_DISTANCE = 4

local connection
local deathConnection
local truss
local folder
local noCollision
local characterToken = 0

local currentWall
local climbing = false

local function cleanup()
	if connection then
		connection:Disconnect()
		connection = nil
	end

	if deathConnection then
		deathConnection:Disconnect()
		deathConnection = nil
	end

	if noCollision then
		noCollision:Destroy()
		noCollision = nil
	end

	if truss then
		truss:Destroy()
		truss = nil
	end

	if folder then
		folder:Destroy()
		folder = nil
	end

	currentWall = nil
	climbing = false
end

local function setupCharacter(character)
	characterToken += 1
	local token = characterToken

	cleanup()

	local humanoid = character:WaitForChild("Humanoid")
	local root = character:WaitForChild("HumanoidRootPart")

	folder = Instance.new("Folder")
	folder.Name = "ClientClimbWalls"
	folder.Parent = workspace

	local function removeTruss()
		if noCollision then
			noCollision:Destroy()
			noCollision = nil
		end

		if truss then
			truss:Destroy()
			truss = nil
		end

		currentWall = nil
		climbing = false
	end

	local function isStandingOnSolidPart()
		local params = RaycastParams.new()
		params.FilterType = Enum.RaycastFilterType.Exclude
		params.FilterDescendantsInstances = {character, folder}
		params.IgnoreWater = true

		local origin = root.Position
		local result = workspace:Raycast(
			origin,
			Vector3.new(0, -SOLID_GROUND_CHECK_DISTANCE, 0),
			params
		)

		if not result or not result.Instance:IsA("BasePart") then
			return false
		end

		if not result.Instance.CanCollide then
			return false
		end

		local verticalVelocity = root.AssemblyLinearVelocity.Y

		return verticalVelocity > -1.5 and math.abs(verticalVelocity) < 3
	end

	deathConnection = humanoid.Died:Connect(function()
		if token ~= characterToken then
			return
		end

		cleanup()
	end)

	connection = RunService.Heartbeat:Connect(function()
		if token ~= characterToken or humanoid.Health <= 0 or not character.Parent or not root.Parent then
			removeTruss()
			return
		end

		if climbing and truss and truss.Parent then
			if isStandingOnSolidPart() then
				removeTruss()
				return
			end

			return
		end

		local params = RaycastParams.new()
		params.FilterType = Enum.RaycastFilterType.Exclude
		params.FilterDescendantsInstances = {character, folder}
		params.IgnoreWater = true

		local origin = root.Position + Vector3.new(0, 1, 0)
		local direction = root.CFrame.LookVector * 4

		local result = workspace:Raycast(origin, direction, params)

		if not result or not result.Instance:IsA("BasePart") or not result.Instance.CanCollide then
			return
		end

		local wall = result.Instance
		local normal = result.Normal

		if math.abs(normal.Y) > 0.25 then
			return
		end

		local horizontalNormal = Vector3.new(normal.X, 0, normal.Z)

		if horizontalNormal.Magnitude < 0.01 then
			return
		end

		horizontalNormal = horizontalNormal.Unit

		currentWall = wall
		climbing = true

		truss = Instance.new("TrussPart")
		truss.Name = "ClientClimbTruss"
		truss.Anchored = true
		truss.CanCollide = true
		truss.CanTouch = true
		truss.CanQuery = true
		truss.Transparency = 0.5
		truss.Material = Enum.Material.ForceField
		truss.Size = Vector3.new(
			2,
			wall.Size.Y + TRUSS_EXTRA_HEIGHT,
			0.5
		)
		truss.Parent = folder

		noCollision = Instance.new("NoCollisionConstraint")
		noCollision.Name = "WallNoCollision"
		noCollision.Part0 = truss
		noCollision.Part1 = wall
		noCollision.Parent = truss

		local wallCenter = wall.Position

		local position = Vector3.new(
			result.Position.X,
			wallCenter.Y,
			result.Position.Z
		) + horizontalNormal * TRUSS_WALL_OFFSET

		local forward = -horizontalNormal
		local right = Vector3.new(-forward.Z, 0, forward.X)
		local up = Vector3.new(0, 1, 0)

		truss.CFrame = CFrame.fromMatrix(
			position,
			right,
			up,
			forward
		)
	end)
end

player.CharacterAdded:Connect(setupCharacter)

if player.Character then
	task.spawn(setupCharacter, player.Character)
end

Advertisements

Comments

0

Did it work for you? Sign in to share your experience.

Sign in to comment

No comments yet

Tried it? Let others know if it works.