How Can I Properly Tween This?

Hey Devs,

I am currently working on this game project called “Classrooms” for around four months already, and it went through various development versions and most of them were old versions of the game that were scrapped. Anways, onto my issue:

I am currently making some furniture for the Classrooms, and I am making this “Projector Screen” thing that I do not understand how to tween properly. I am new to Roblox Scripting, yet my building skills are good. Here is my code (and a video) if you need it:


--Close
script.Parent.Parent.PullBar.Prox_Prompt.Triggered:Connect(function()
	game:GetService("TweenService")
	local info = TweenInfo.new(
		6, -- Time
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.Out, -- EasingDirection
		0, -- Loop
		false, -- Reverse
		0 -- Delay
	)
	local tween = game:GetService("TweenService"):Create(script.Parent.Parent.Screen, info, { Size = Vector3.new(script.Parent.Parent.PullBar_Goal.Size.Y) })
	local tween2 = game:GetService("TweenService"):Create(script.Parent.Parent.PullBar, info, { Position = Vector3.new(script.Parent.Parent.Screen_Goal.Position.Y) })
	tween:Play()
	tween2:Play()
	task.wait(6)
	tween:Cancel()
	tween2:Cancel()
end) 

--Open

--wip
5 Likes

Where’s the video? Please show your video. Thanks.

1 Like

you’re tweening just fine other than canceling the tween even though it would already be finished

local TS = game:GetService("TweenService")
local info = TweenInfo.new(6,Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
-- you aren't using Loop, Reverse, or Delay so just remove them
-- also keep TS and info outside of functions if you plan to reuse them

local Holder = script.Parent.Parent -- avoid typing 'script.Parent' so many times

local function Close()
-- you don't need to make variables for the tweens if you aren't reusing them
  TS:Create(Holder.Screen, info, {Size = Holder.PullBar_Goal.Size}):Play()
  TS:Create(Holder.PullBar, info, {Position = Holder.Screen_Goal.Position}):Play()
-- canceling isn't nessecary when the tween already finished
end

Holder.PullBar.Prox_Prompt.Triggered:Connect(Close)
1 Like

I cant show the video because it returns an error while uploading it to the dev forum :frowning:

1 Like

Tried your code, still is broken.

What I expect to happen:

The Screen to go upwards in size to the goal point (with no change to the X or Z sizes), with the Pull Bar staying on the screen. And I expect it to do it the opposite way while reopening it.

Actual behavior:

The Screen rapidly shrinking in size, not knowing where the goal is while the pull bar is going far outside of the room.

i had to put it in text format because the video wasn’t uploading to the dev forum :confused:

1 Like

You can upload it to youtube, set it to “not listed” or something around that, and send us the link of it

1 Like

I will re-record it on my main PC later and see if it uploads then…

1 Like

Pretty sure you need an x y and z for the Vector3.

1 Like

Tried your code, still is broken.

i didn’t aim to fix anything i only shortened it since i thought you wanted someone to review your code

i think the problem is with your goals
you’re going to Y instead of the position/size

TS:Create(Holder.Screen, info, {Size = Vector3.new(Holder.PullBar_Goal.Size.Y)}):Play()
TS:Create(Holder.PullBar, info, {Position = Vector3.new(Holder.Screen_Goal.Position.Y)}):Play()
TS:Create(Holder.Screen, info, {Size = Holder.PullBar_Goal.Size}):Play()
TS:Create(Holder.PullBar, info, {Position = Holder.Screen_Goal.Position}):Play()
1 Like

yeah i looked at it

charcharchar

1 Like

view the following reply
this is required text