Gate not turning

There is an error on line 5.

A script in serverscriptservice:

local leftGate = game.Workspace.BeachGateLeft
local rightGate = game.Workspace.BeachGateRight
local button = game.Workspace.BGateButton

rightGate.CFrame = CFrame.new(Vector3.new(-245.743, 45.199, 426.951) (CFrame.fromEulerAnglesXYZ(0, 0, 0)))
leftGate.CFrame = CFrame.new(Vector3.new(-240.499, 45.199, 426.942) (CFrame.fromEulerAnglesXYZ(0, 180, 0)))

game.Workspace.BGateButton.ProximityPrompt.PromptButtonHoldEnded:Connect(function(player)
	if player.Team == not game.Teams["King(s)"] or game.Teams.Guards or game.Teams.Developer then
		return
	end
	rightGate.CFrame = CFrame.new(Vector3.new(-247.947, 45.199, 424.708) (CFrame.fromEulerAnglesXYZ(0, 90, 0)))
	leftGate.CFrame = CFrame.new(Vector3.new(-238.458, 45.199, 424.708) (CFrame.fromEulerAnglesXYZ(0, 90, 0)))
	
	wait(5)
	
	rightGate.CFrame = CFrame.new(Vector3.new(-245.743, 45.199, 426.951) (CFrame.fromEulerAnglesXYZ(0, 0, 0)))
	leftGate.CFrame = CFrame.new(Vector3.new(-240.499, 45.199, 426.942) (CFrame.fromEulerAnglesXYZ(0, 180, 0)))
end)s

You may also use TweenService in some situations

1 Like

Is this the situation I can use tween service?

I may be wrong, but I think it’s because you are attempting to call a Vector3 value within a CFrame value.

I did a teleport block before with CFrame.new(Vector3.new() and it worked so I don’t think that’s the case.

I think you could , I also used this technique first when making a gate, but realized that its easier to make a tween, atleast for me
https://developer.roblox.com/en-us/api-reference/class/TweenService

I checked it out and I saw Tween.new(5) does 5 represent how long it will play?

Yes the number does represent the speed/how long it will play

1 Like

I think when you are doing Tween.New() or creating a tween whatsoever it should display what property the current parameter represents

1 Like

Im confused with tween service

you are going to want to multiply the values to get a cframe, so like

rightGate.CFrame = CFrame.new(Vector3.new(-245.743, 45.199, 426.951) *(CFrame.fromEulerAnglesXYZ(0, 0, 0)))
leftGate.CFrame = CFrame.new(Vector3.new(-240.499, 45.199, 426.942) *(CFrame.fromEulerAnglesXYZ(0, 180, 0)))

also, i would recommend changing the 180 to something less because 180 in Euler’s angle is too much, I would recommend math.pi instead.

local leftGate = game.Workspace.BeachGateLeft
local rightGate = game.Workspace.BeachGateRight
local button = game.Workspace.BGateButton

local TweenService = game:GetService("TweenService")


local tweenInfo = TweenInfo.new(5)


local tween1 = TweenService:Create(leftGate, tweenInfo, {Position = Vector3.new(0, 10, 20)})


tween1:Play()

Where would I add that in?

right where you had it before

local leftGate = game.Workspace.BeachGateLeft
local rightGate = game.Workspace.BeachGateRight
local button = game.Workspace.BGateButton

rightGate.CFrame = CFrame.new(Vector3.new(-245.743, 45.199, 426.951) *(CFrame.fromEulerAnglesXYZ(0, 0, 0)))
leftGate.CFrame = CFrame.new(Vector3.new(-240.499, 45.199, 426.942) *(CFrame.fromEulerAnglesXYZ(0, math.pi, 0)))

game.Workspace.BGateButton.ProximityPrompt.PromptButtonHoldEnded:Connect(function(player)
	if player.Team == not game.Teams["King(s)"] or game.Teams.Guards or game.Teams.Developer then
		return
	end
	rightGate.CFrame = CFrame.new(Vector3.new(-245.743, 45.199, 426.951) *(CFrame.fromEulerAnglesXYZ(0, .5*math.pi, 0)))
leftGate.CFrame = CFrame.new(Vector3.new(-240.499, 45.199, 426.942) *(CFrame.fromEulerAnglesXYZ(0, .5*math.pi, 0)))
	
	wait(5)
	
	rightGate.CFrame = CFrame.new(Vector3.new(-245.743, 45.199, 426.951) *(CFrame.fromEulerAnglesXYZ(0, 0, 0)))
leftGate.CFrame = CFrame.new(Vector3.new(-240.499, 45.199, 426.942) *(CFrame.fromEulerAnglesXYZ(0, math.pi, 0)))
end)
tween1:Play()

although the way it’s formated isn’t going to tween it

why does it not tween? no errors in output

im trying to just make the gate turn can someone please help

Okay ; I will help you.

local target --this is your gate,
local tweenservice = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(1,Enum.EasingStyle.Quint,Enum.EasingDirection.Out)
				local TheTween = tweenservice:Create(target,tweeninfo,{Orientation= Vector3.new(1,1,1) })
					TheTween:Play() -- when you want to play your tween

When you have your Orientation put your own orientation values to it!
You need to put the what the final orientation is going to be for ex, if you want it to turn to 90 degrees in all directions you would put 90,90,90.
first parameter is for X, second for Y and last one for Z
In tween it does not matter at what orientation the part already is because it will turn it from the current orientation to the desired final orientation

if you need multiple gates you need to just make a new tweenservice:Create() and play it

Okay I made a script, it prints finished but won’t turn the gate

local Lgate = game.Workspace.Gate.BeachGateLeft
local Rgate = game.Workspace.Gate.BeachGateRight

local LOldPosition, LOldRotation = Vector3.new(-240.499, 45.199, 426.942), Vector3.new(0,-180,0)

local LNewPosition, LNewRotation = Vector3.new(-237.886, 45.373, 424.74), Vector3.new(0, 90, 0)

local ROldPosition, ROldRotation = Vector3.new(-245.743, 45.199, 426.951), Vector3.new(0, 0, 0)

local RNewPosition, RNewRotation = Vector3.new(-248.303, 45.373, 424.551), Vector3.new(0,90,0)

local clickDetec = game.Workspace.BGateButton.ClickDetector
local open = false

print("a")

clickDetec.MouseClick:Connect(function(player)
	print("b")
	print("d")
	if open == false then
		print("e")
		Lgate.Position = LNewPosition
		Lgate.Orientation = LNewRotation
		Rgate.Position = RNewPosition
		Rgate.Orientation = RNewRotation
		open = true

	end
	if open == true then
		print("F")
		Lgate.Position = LOldPosition
		print("f2")
		Lgate.Orientation = LOldRotation
		Rgate.Position = ROldPosition
		Rgate.Orientation = ROldRotation
		open = false
		print("finished")
	end
end)

Nevermind just did it another way.