(SOLVED) Prison Life Style Gate System

Ok, I’ll check it out, and see if I can learn something. If not, i’ll return back crying…

Please Give solution :)) I did script for you… Just change local model = your gate model :smiley:

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


1 Like

So if the player clicks the button, the gate will open?

Yes change

local model= "YOUR GATE MODEL"

and change

local Offset=Vector3.new(-10, 0, 0)   

X or Z depends which side you opening from and how much you want to open it…

1 Like

Alright, I’ll give it a try… Do I put the script inside the button…??.. Yes, I’m very dumb indeed…

Maybe this will help you.

1 Like

I did all of the code for you with the ClickDetector just change the variables this works :slight_smile: 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)
1 Like

Awesome, I’ll give it a try! :smiley:

robloxapp-20220227-0120003.wmv (2.4 MB)

1 Like

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

1 Like

also if you want a cooldown for the button just add a wait() function into the tween.completed… like this, make sure to add the wait() for both closing and opening. there is 2 tween completed functions can you give solution?

tween.Completed:Connect(function()

					model.PrimaryPart.Position = pos+Offset
					active=false
wait(5)
					coroutine.yield()
				end)
1 Like

Is there a way you could explain how to do this? I’ve looked at the post of the other person, but it only seems to show the option where the part swing (for example a normal door)?

I can’t help you anymore than this, I don’t think anyone can, I’ve made a map just for you which in UNCOPYLOCKED so u can download it and there the gate work when u press the green block so u can just copy that to you game

https://www.roblox.com/games/8952316053/GateOpeningScript

1 Like

Ok, that’s completely understandable, thanks alot for your efforts to help a dumb person :laughing: :grinning:

You’re not dumb, programming has a gradual learning curve, you do not become a master at a craft if you dont practice, with enough experience you will start grasping more than you thought you could as long as you don’t give up :smiley: ! good luck give solution thanks ~~ Rocky

1 Like

Just a quick thing. I tried customizing the gate that you presented to fit the fences, but after I removed some parts, the gate won’t open/work. I also tried to only change the transparency of the parts that I tried to remove, but it also wasn’t working.

you can only add parts inside of the model that are className “Part” otherwise it will throw a error

If you added any models inside od the gate model you want to ungroup that aswell

Ok, understood. I will check if I added anything inside that caused an error, thanks!

1 Like

I did not add any models whatsoever.