What am I trying to do?
I’m trying to make an elevator system and whenever a player is in it, it moves to the floor you requested it to down or up to.
Issue?
The issue is I’m using the primary part of a model(the elevator) and welding every part to the primary part. I’m moving the primary part and unanchoring every other part in the model but using a weldconstraint to keep them somewhat anchored or held together. The problem is on the primarypart is working.
What have I tried?
I’ve made another mini elevator in another studio that was a model and it works perfectly fine, although the script is not as complex it has the main features i’m using in the script for my game to make this elevator work properly. I’ve tried activating weld constraints which I didn’t even realize but they weren’t the main source of my issue. I’ve also tried to set a collision group with the outer stone wall and the elevator parts so they didn’t touch because I thought it was possible that the elevator tunnel was so tight that it was holding the anchored parts.
Part of local script i’m using regarding elevator:
inside.Touched:Connect(function()
local attribute1 = outside:GetAttribute("Activated")
local attribute2 = inside:GetAttribute("Activated")
local shaftgoal = shaftgoals:WaitForChild("BackGoal")
if attribute2 == false then
outside:SetAttribute("Activated", false)
inside:SetAttribute("Activated", true)
task.spawn(elevatormodule.closeshaft,shaft,shaftgoal)
task.spawn(elevatormodule.closedoors,left, right,doorgoalstable[3],doorgoalstable[1])
task.spawn(elevatormodule.move,elevator,elevatorgoals, left, right,doorgoalstable[4],doorgoalstable[2], shaft, shaftgoal)
elseif attribute2 == true then return end
end)
outside.Touched:Connect(function()
local attribute1 = outside:GetAttribute("Activated")
local attribute2 = inside:GetAttribute("Activated")
local shaftgoal = shaftgoals:WaitForChild("BackGoal")
if attribute1 == false then
inside:SetAttribute("Activated", false)
outside:SetAttribute("Activated", true)
task.spawn(elevatormodule.closeshaft,shaft,shaftgoal)
task.spawn(elevatormodule.closedoors,left, right,doorgoalstable[3],doorgoalstable[1])
elseif attribute1 == true then return end
end)
Module for elevator:
move = function(elevator,elevatorgoals, left, right, rightgoal, leftgoal, shaft, frontgoal)
local area = elevator.PrimaryPart
print(area)
local goalstable = {
elevatorgoals:FindFirstChild("Goal3"),
elevatorgoals:FindFirstChild("Goal2"),
elevatorgoals:FindFirstChild("Goal1")
}
print(area.Position)
print(goalstable[1].Position)
print(goalstable[2].Position)
if area.Position == goalstable[1].Position then
print("Success")
local randomnumber = math.random(4,7)
local info = TweenInfo.new(
randomnumber,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local tween1 = TS:Create(area, info, {Position = goalstable[2].Position})
tween1.Completed:Connect(function()
print("Completed")
local info = TweenInfo.new(
3,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local tween1 = TS:Create(left, info, {Position = leftgoal.Position})
local tween2 = TS:Create(right, info, {Position = rightgoal.Position})
local tween3 = TS:Create(shaft,info,{Position = frontgoal.Position})
tween1:Play()
tween2:Play()
tween3:Play()
end)
tween1:Play()
end
end,
Image of explorer tab:
Pictures of elevator: