I am creating a Wallrun Script. This script will allow players to hold onto walls and move in the X direction swiftly.
To achieve this effect, I am using a Prismatic Constraint and Setting the Humanoid's State Type to physics, so the process cannot be interrupted by any other type of state.
Mostly the problem is based on the Attachment1 Placement.
Currently, I'm setting Attachment1's World Position to this: att2.WorldPosition = rayres.Instance.Position * Vector3.new(rayres.Instance.Size.X + (rayres.Instance.Size.X / 2),0,0)
This is to make sure that Attachment1 can end at the edge of the part.
Obviously, this doesn't work. Here is my code, test it out for your self and you'll see what I mean.
local left = nil local right = nil local isWallrunning = nil local RunService = game:GetService('RunService') local RunServ = game:GetService("RunService") local RootPart = script.Parent:WaitForChild("HumanoidRootPart") local rayP = RaycastParams.new() rayP.FilterDescendantsInstances = {script.Parent, workspace.Baseplate} rayP.FilterType = Enum.RaycastFilterType.Blacklist RunService.Heartbeat:Connect(function(dt) local origin = RootPart.Position local direction = RootPart.CFrame.RightVector * 3 local rayres = workspace:Raycast(origin, direction, rayP) if rayres and left ~= true then right = true if rayres.Instance == workspace.Baseplate then return end local PrismaticConstraint = Instance.new('PrismaticConstraint') local att1 = Instance.new('Attachment') local att2 = Instance.new('Attachment') PrismaticConstraint.Parent = RootPart RootPart.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Physics) att1.Parent = RootPart att2.Parent = rayres.Instance att2.WorldPosition = rayres.Instance.Position * Vector3.new(rayres.Instance.Size.X + (rayres.Instance.Size.X / 2),0,0) PrismaticConstraint.Attachment0 = att1 PrismaticConstraint.Attachment1 = att2 end end)
I've been stuck on this part for about 2 hours, I'm just so confused.
By the way, I'm testing this in Studio, and with R15.