How to make barrier open/close

How do i make this barrier go up to the invisible part shown in the picture. And i mean smoothly not just teleporting it.

Explorer:
image
Arm is the arm that is visible.
ArmUp/Down are invisible parts where i want the barrier to move to.
BasePart is obviously the white pole on the left.

Script:

local prox = script.Parent.ProximityPrompt

prox.Triggered:Connect(function(plr)
	if plr:GetRankInGroup(35020333) >= 9 then
		
	end
end)

I’ve tried searching on youtube and google but I can’t find anything that is what im trying to achieve. Any help would be appreciated :smile:

13 Likes

Try using the TweenService to smoothly transition the barrier from one spot to another. You can find the documentation here

4 Likes

Hello. I’ve already tried this and what happened is it also moved on the X axis. I want it to just go up and down but it like moved back and fourth on the X axis also. Is there a workaround?

4 Likes

record the CFrame of the open and close positions

then tween between the 2 cframes

6 Likes

Also make sure you rotate within the BasePart’s axis

3 Likes

You would call the variable of the barrier (the not invisible one).CFrame then get another variable of the invisible part’s.CFrame, set the TweenInfo parameters you want, then :Play() it after the ProximityPrompt has been triggered

3 Likes

just record them manually

you can do

local cframe = position * CFrame.fromOrientation(orientation)

and you can see position/orientation in the properties tab
also they are vectors like Vector3.new(1,2,3)

3 Likes

Not sure what “Arm”, “ArmDown”, “ArmUp”, etc are, but if they’re different parts of the barrier, I suggest first welding them all together onto a different ANCHORED part (i called it ROOTPART in the script).

This script would move the arm up

local TweenService = game:GetService('TweenService')

local RootPart = EntranceGate.ROOTPART -- the part where all the other parts are welded to

---
TweenService:Create(RootPart, TweenInfo.new(3), {CFrame = ArmUp.CFrame}):Play() -- i assume ArmUp is the position where the arm will be when its up?
3 Likes

This might work! :smile:

local prox = script.Parent.ProximityPrompt
local entrancegate = script.Parent.Parent
local tweenservice = game:GetService("TweenService")
local uptween = tweenservice:Create(entrancegate.Arm, TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0),{["CFrame"]=entrancegate.ArmUp.CFrame})

local downtween = tweenservice:Create(entrancegate.Arm, TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0),{["CFrame"]=entrancegate.ArmDown.CFrame})

local openval = false

prox.Triggered:Connect(function(plr)
	if plr:GetRankInGroup(35020333) >= 9 then
                if openval then
                        downtween:Play()
                        openval = false
                else
                        openval = true
                        uptween:Play()
		end
	end
end)

Oops made some mistakes. Just updated it now!

4 Likes

Hello. Thanks for replying. I’m not exactly sure where I need to put this in my script. So i’ve made a script that tweens it but it still does it wrong. I’m hoping you can tell me where I would put this?

local prox = script.Parent.ProximityPrompt
local model = game.Workspace.Map:FindFirstChild("EntranceGate")
local armUp = model.ArmUp
local armDown = model.ArmDown
local arm = model.Arm

local TweenService = game:GetService("TweenService")

prox.Triggered:Connect(function(plr)
	if plr:GetRankInGroup(35020333) >= 9 then
		local tween	= TweenService:Create(arm, TweenInfo.new(2), {CFrame = armUp.CFrame})
		tween:Play()
	end
end)

Sorry I’m a bit of a rookie when it comes to tweening :sweat_smile:

3 Likes

Try the script I made. I think it will work. :+1:

By the way, put my script’s text in the same script that is showed in the image. :smile:

2 Likes

Hello. This is the same result as the script i made for Happyas answer.
Here is a video of whats happening when i only want it to move up and down not side to side.

Sorry for the bad quality. But as u can see in the video the it doesnt react like a barrier would in real life.
robloxapp-20250104-0158461.wmv (411.2 KB)

2 Likes

maybe connect the barrier to the pole with a motor6d and then you can change the C0 or C1 orientation to rotate around the pole as a pivot

2 Likes

Ah I see now.

That is definitely the best method for what you want.

2 Likes

Imma do some experimenting in studio and (hopefully) get back to you with an answer!

2 Likes

Yes but i dont know how to do that :sweat_smile:
Can you show me how i do that? Cuz I dont quite get it. Sorry.

2 Likes

Okay thank you :slight_smile:
asjdnahsjbdasbdhasbdhasbd

2 Likes

I tried testing with motor 6ds and discovered that they’re not going to work.

However, I did some further research and came up with a possible fix for your issue!

Step 1:
Insert a new part where you want the joint to be. Make sure this part is anchored, small, and transparent.

Step 2: Add a WeldConstraint instance under the new part. Make sure that the weld’s Part0 property is set to the new part and its Part1 property is set to the arm.

Step 3: Make sure the arm is unanchored.

Then all we need to do is to tween the rotation of the part and the arm will turn at that point!

You can work on setting that up and I’ll start on a script to tween it. :+1: :grin:

2 Likes

Okay. I am done with setting up the weldconstraint :smile:
Thanks for helping me by the way it’s very nice of you to take time out of your day to help me.

Let me know when the script is ready

3 Likes

Thanks! That’s really kind of you to say! :grin:

I’ve been working on the script, and I was able to reuse quite a bit of things from my first attempt:

local prox = script.Parent.ProximityPrompt
local joint = --the joint part (i don't know where you parented it)
local tweenservice = game:GetService("TweenService")
local uptween = tweenservice:Create(joint, TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0),{["Orientation"]="vector3 value of the orientation of the joint when open"})

local downtween = tweenservice:Create(joint, TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0),{["Orientation"]=joint.Orientation})

local openval = false

prox.Triggered:Connect(function(plr)
	if plr:GetRankInGroup(35020333) >= 9 then
                if openval then
                        downtween:Play()
                        openval = false
                else
                        openval = true
                        uptween:Play()
		end
	end
end)

Hope this helps!

1 Like