Tweening Problem

  1. What do you want to achieve? Keep it simple and clear!
    I want to achieve a blast door that goes up when you press a button, and after 3 seconds the blast door goes back down.
  2. What is the issue? Include screenshots / videos if possible!
    Basically what happens is that instead of delaying to go in reverse and the part going back to its original position, there is no delay and it immediatly happens.
  3. What solutions have you tried so far?
    None so far, just makig a post here.

Code:

local click=script.Parent
local tweenservice=game.TweenService
local cooldown=false
local part=game.Workspace.BlastDoor
local pos=Vector3.new(994.629, 12.635, 714.405)
click.MouseClick:Connect(function(plr)
	if cooldown==false and game.Workspace.DoorOpen.Value==false then
		cooldown=true
		game.Workspace.DoorOpen.Value=true
		local tweeninfo=TweenInfo.new(
			5,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.Out,
			2,
			true,
			3
			
		)
		local tween=tweenservice:Create(part, tweeninfo,{Position=pos})
		tween:Play()
		wait(5)
		cooldown=false
		game.Workspace.DoorOpen.Value=true
	end
end)```
Yes I know the code is super sloppy and inneficient
1 Like

Try doing:

  1. Tween the door to an open state
  2. task.wait(3)
  3. Tween the door to a closed state

Not gonna give you the script, that’d be cheating! We’ll give you help though.

3 Likes

You are setting the tween to open the door which opens it over 3 seconds in your tweeninfo.
But then you wait(5) (which should be task.wait(5)) which means the tween happens over 3 seconds, but the task.wait(5) starts immediately after the tween starts. In a perfect world this would only allow the door pause to be 2 seconds.
Since your easing style is Out, the tween should only go in one direction.

cooldown=false
game.Workspace.DoorOpen.Value=true

You already set DoorOpen to true at the beginning of the clicked function.

Where is the section of script that closes the door?

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.