I made a ladder that a player can place that can extend and retract for my game, but it was always anchored so the player was able to climb on it, place a new one (which deleted the older) while jumping to land on it to get higher. So a fix to this was having the ladder be unanchored for 1.5sec that lets people also push it around so we can make more fun obstacles, to then be anchored when it’s over. However, the ladder completely stopped working, I tried messing around with welds hoping they would work but they didnt.
Any help?
local Toggle = false
--[[
Toggles the state of Ladder from extended to retracted
]]
function LadderModule.LadderToggleState(Truss, Tweeninfo)
local Origin = Truss.Parent.Parent:FindFirstChild("Base ladder").Truss.Position
local Destination = (Truss.CFrame * CFrame.new(0,Truss.Size.Y-2,0)).Position
local Direction = Destination-Origin
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {script.Parent.Parent,workspace.Characters}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
local GoalExtend = {Position = Destination}
local GoalRetract = {Position = Origin}
local Raycast = workspace:Raycast(Origin, Direction, raycastParams)
Truss.StoneSlide:Play()
if Raycast and Raycast.Position then
local part = Instance.new("Part")
part.Anchored = true
part.Position = Raycast.Position
part.Name = "RayPart"
end
if not Toggle then
Toggle = true
local Tween = TweenService:Create(Truss, Tweeninfo, GoalExtend)
if Raycast and Raycast.Instance then
print(Raycast, Raycast.Instance)
--Tween = TweenService:Create(Truss, Tweeninfo, {Position = (CFrame.new(Raycast.Position) * CFrame.new(0,Truss.Size.Y/2,0).Position)})
local pos1 = CFrame.new(Destination)
Tween = TweenService:Create(Truss, Tweeninfo, {Position = (Truss.CFrame * CFrame.new(0,(Truss.Position-Raycast.Position).Magnitude+1.5 - Truss.Size.Y/2,0)).Position})--CFrame.new(Raycast.Position - Vector3.new(0,Truss.Size.Y/2,0)).Position})
else
Tween = TweenService:Create(Truss, Tweeninfo, GoalExtend)
end
Tween:Play()
Tween.Completed:Wait()
else
Toggle = false
local Tween = TweenService:Create(Truss, Tweeninfo, GoalRetract)
Tween:Play()
Tween.Completed:Wait()
end
end
(desceandents of the ladder model)
video of it