I’m attempting to create a wall climbing script by using alignposition and alignorientation, however the attachment that should have been at the intersection of the ray is in midair with no parts near?
I have tried to solve this on my own but I just can’t.
local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space then
local rayparam = RaycastParams.new()
rayparam.FilterDescendantsInstances = {plr.Character,game.Workspace.Baseplate}
rayparam.FilterType = Enum.RaycastFilterType.Blacklist
local ray = workspace:Raycast(plr.Character:WaitForChild("HumanoidRootPart").Position, plr.Character:WaitForChild("HumanoidRootPart").CFrame.lookVector * 5,rayparam)
if ray then
if plr.Character:FindFirstChild("Climbing").Value == false then
plr.Character:FindFirstChild("Climbing").Value = true
else
plr.Character:FindFirstChild("Climbing").Value = true
local Attachment = Instance.new("Attachment")
Attachment.Parent = ray.Instance
Attachment.Position = ray.Position
print(ray.Instance.Position)
local Attachment2 = Instance.new("Attachment")
Attachment2.Parent = plr.Character:WaitForChild("HumanoidRootPart")
local bodygyro = Instance.new("AlignOrientation")
bodygyro.Name = "ClimbGyro"
bodygyro.MaxTorque = Vector3.new(30000,30000,30000)
bodygyro.Parent = plr.Character:WaitForChild("HumanoidRootPart")
bodygyro.Attachment0 = Attachment
bodygyro.Attachment1 = Attachment2
bodygyro.RigidityEnabled = true
bodygyro.ReactionTorqueEnabled = true
local bodypos = Instance.new("AlignPosition")
bodypos.Name = "ClimbPosition"
bodypos.Parent = plr.Character:WaitForChild("HumanoidRootPart")
bodypos.Attachment0 = Attachment
bodypos.Attachment1 = Attachment2
bodypos.ReactionForceEnabled = true
end
end
end
end)