I’m making a Prison right now, and this is what I am trying to make:
What do you want to achieve? I want to make a Front Gate like the Prison Life one
What is the issue? I tried some Roblox Studio models (Click to Open
Sliding Door) but if I add another part to the model,
the part doesn’t move with the main part.
What solutions have you tried so far? I tried looking on YouTube, but the
Videos only include Single-Part
Gates/Sliding Gates
The gate should open when you click a button, have a cooldown of 5 Seconds and the gate being a model with multiple parts attached to it.
Assuming whatever you are using uses tweens, make sure the extra parts attached to the part being tweened are unanchored and welded to the part being tweened.
Technically no, but efficiently yes. They could also use a :SetPrimaryPartCFrame loop which some sliding door free models so, which they said they were looking at those, or move all of the parts individually (no clue why anyone would do this lol).
Please Give solution :)) I did script for you… Just change local model = your gate model
local TweenService = game:GetService("TweenService")
local Offset=Vector3.new(-10, 0, 0)
local TimeTakenForAnimation=5
local model= game.Workspace.ModelX
for i,v in pairs (model:GetChildren()) do
coroutine.wrap(function()
local goal = {}
goal.Position = v.Position+Offset
local tweenInfo = TweenInfo.new(TimeTakenForAnimation)
local tween = TweenService:Create(v, tweenInfo, goal)
tween:Play()
coroutine.yield()
end)()
end
I did all of the code for you with the ClickDetector just change the variables this works I tested it
local TweenService = game:GetService("TweenService")
local Offset=Vector3.new(-10, 0, 0)
local TimeTakenForAnimation=5
local model= game.Workspace.ModelX
local TweenService = game:GetService("TweenService")
local Offset=Vector3.new(-10, 0, 0)
local TimeTakenForAnimation=5
local model= game.Workspace.ModelX
local pos = model.PrimaryPart.Position
local ClickDetector = script.Parent.ClickDetector
local OpenBool = false
local active = false
ClickDetector.MouseClick:Connect(function()
if OpenBool==false and active==false then
OpenBool=true
active=true
for i,v in pairs (model:GetChildren()) do
coroutine.wrap(function()
local goal = {}
goal.Position = v.Position+Offset
local tweenInfo = TweenInfo.new(TimeTakenForAnimation)
local tween = TweenService:Create(v, tweenInfo, goal)
tween:Play()
tween.Completed:Connect(function()
model.PrimaryPart.Position = pos+Offset
active=false
coroutine.yield()
end)
end)()
end
else
if OpenBool==true and active==false then
OpenBool=false
active=true
for i,v in pairs (model:GetChildren()) do
coroutine.wrap(function()
local goal = {}
goal.Position = v.Position-Offset
local tweenInfo = TweenInfo.new(TimeTakenForAnimation)
local tween = TweenService:Create(v, tweenInfo, goal)
tween:Play()
tween.Completed:Connect(function()
model.PrimaryPart.Position = pos
active=false
coroutine.yield()
end)
end)()
end
end
end
end)
Also I added the variables twice accident you can remove the first 4 lines
local TweenService = game:GetService("TweenService")
local Offset=Vector3.new(-10, 0, 0)
local TimeTakenForAnimation=5
local model= game.Workspace.ModelX