You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want it so if my hands are on top of the wall my hands carry me and i stay upright and i dont fall off and can move normally or jump
-
What is the issue? i slide off unless at very certain angles or positions
heres a video that shows you my issue (sorry couldnt find a video of what i want but its simple) https://youtu.be/Oje7n89ukjc
- What solutions have you tried so far? i did look for a soltuion, no help, i tried velocity i tried to disable gravity i tried to anchor or use welds, motor6ds, nothing helps at all, not even detecting when your hand is at top, no use of any of these
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
local torso = char:WaitForChild("Torso")
local rootPart = char:WaitForChild("HumanoidRootPart")
local rightArm = char:WaitForChild("Right Arm")
local leftArm = char:WaitForChild("Left Arm")
local rightLeg = char:WaitForChild("Right Leg")
local leftLeg = char:WaitForChild("Left Leg")
local rightShoulder = torso:WaitForChild("Right Shoulder")
local leftShoulder = torso:WaitForChild("Left Shoulder")
local rightHip = torso:WaitForChild("Right Hip")
local leftHip = torso:WaitForChild("Left Hip")
task.wait(0.5)
local EXTENSION_RATE = 2
local MAX_EXTENSION = 5
local ORIGINAL_SIZE = Vector3.new(1, 2, 1)
local ARM_ROTATION = CFrame.Angles(math.rad(90), 0, 0)
local extending = false
local currentExtension = 0
local rightArmInWall = false
local leftArmInWall = false
local origC0s = {
RightShoulder = rightShoulder.C0,
LeftShoulder = leftShoulder.C0,
RightHip = rightHip.C0,
LeftHip = leftHip.C0
}
for _, part in ipairs(char:GetDescendants()) do
if part:IsA("BasePart") then
if part.Name:find("Arm") then
part.CollisionGroup = "CharacterArms"
part.CanCollide = true
else
part.CollisionGroup = "CharacterBody"
end
end
end
rightArm.CustomPhysicalProperties = PhysicalProperties.new(0.7, 2, 0, 100, 0)
leftArm.CustomPhysicalProperties = PhysicalProperties.new(0.7, 2, 0, 100, 0)
local function enforceArmCollision()
if rightArm.Parent then
rightArm.CollisionGroup = "CharacterArms"
rightArm.CanCollide = true
end
if leftArm.Parent then
leftArm.CollisionGroup = "CharacterArms"
leftArm.CanCollide = true
end
end
RunService.PreSimulation:Connect(enforceArmCollision)
humanoid.StateChanged:Connect(function()
enforceArmCollision()
task.wait()
enforceArmCollision()
end)
rightArm:GetPropertyChangedSignal("CanCollide"):Connect(function()
if not rightArm.CanCollide then rightArm.CanCollide = true end
end)
leftArm:GetPropertyChangedSignal("CanCollide"):Connect(function()
if not leftArm.CanCollide then leftArm.CanCollide = true end
end)
local function checkArmInWallTop(arm)
for _, part in ipairs(arm:GetTouchingParts()) do
if part.Name == "WallTop" and part:IsA("BasePart") then
return true
end
end
return false
end
RunService.Heartbeat:Connect(function()
if extending and currentExtension > 2 then
rightArmInWall = checkArmInWallTop(rightArm)
leftArmInWall = checkArmInWallTop(leftArm)
else
rightArmInWall = false
leftArmInWall = false
end
end)
rightShoulder.Enabled = false
leftShoulder.Enabled = false
RunService.Heartbeat:Connect(function()
rightShoulder.Enabled = false
leftShoulder.Enabled = false
end)
local rightWeld = Instance.new("Weld")
rightWeld.Part0 = torso
rightWeld.Part1 = rightArm
rightWeld.C0 = origC0s.RightShoulder * ARM_ROTATION
rightWeld.Parent = torso
local leftWeld = Instance.new("Weld")
leftWeld.Part0 = torso
leftWeld.Part1 = leftArm
leftWeld.C0 = origC0s.LeftShoulder * ARM_ROTATION
leftWeld.Parent = torso
local function lockArmRotation()
local armCenterOffset = Vector3.new(0, -currentExtension / 2, 0)
local forwardOffset = currentExtension / 2
local upOffset = currentExtension / 2
local rightPos = origC0s.RightShoulder.Position
local leftPos = origC0s.LeftShoulder.Position
local rightAdjust = Vector3.new(0.5, 0, -0.5 - forwardOffset)
local leftAdjust = Vector3.new(-0.5, 0, -0.5 - forwardOffset)
rightWeld.C0 = (CFrame.new(rightPos + armCenterOffset + rightAdjust) * ARM_ROTATION) + Vector3.new(0, upOffset, 0)
leftWeld.C0 = (CFrame.new(leftPos + armCenterOffset + leftAdjust) * ARM_ROTATION) + Vector3.new(0, upOffset, 0)
end
local function updateLimbScaling(dt)
local dir = extending and 1 or -1
currentExtension += dir * EXTENSION_RATE * dt
currentExtension = math.clamp(currentExtension, 0, MAX_EXTENSION)
local newSize = ORIGINAL_SIZE + Vector3.new(0, currentExtension, 0)
rightArm.Size = newSize
leftArm.Size = newSize
rightLeg.Size = newSize
leftLeg.Size = newSize
local offset = Vector3.new(0, currentExtension / 2, 0)
rightHip.C0 = origC0s.RightHip - offset
leftHip.C0 = origC0s.LeftHip - offset
end
UserInputService.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.E then
extending = true
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
extending = false
end
end)
RunService.RenderStepped:Connect(function(dt)
updateLimbScaling(dt)
lockArmRotation()
if (rightArmInWall or leftArmInWall) and extending then
if rootPart.AssemblyLinearVelocity.Y < 0 then
rootPart.AssemblyLinearVelocity = Vector3.new(
rootPart.AssemblyLinearVelocity.X,
0,
rootPart.AssemblyLinearVelocity.Z
)
end
local antiGravity = rootPart:FindFirstChild("AntiGravityForce")
if not antiGravity then
antiGravity = Instance.new("BodyVelocity")
antiGravity.Name = "AntiGravityForce"
antiGravity.MaxForce = Vector3.new(0, math.huge, 0)
antiGravity.Velocity = Vector3.new(0, 0, 0)
antiGravity.Parent = rootPart
end
else
local antiGravity = rootPart:FindFirstChild("AntiGravityForce")
if antiGravity then
antiGravity:Destroy()
end
end
end)
this is my script.
please try to help me, my goal is to stay upright and my arm holds me on the edge and not slide off,