Tween getting called out of nothing

  1. What do you want to achieve? Keep it simple and clear!
    I want to fix my issue with the tweenservice. (The tween “RightLowering:Play()” playing for no reason after it’s initial call.)

  2. What is the issue? Include screenshots / videos if possible!
    The function getting called while it is suppost to be waiting for 20 sec

In this video (The one below) it almost works, but something is getting called at the end that tweens it back out again. (This is my issue)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried looking for other people having the same issue (didn’t find anyone).
  • I have tried removing other tweens to check if they cause the behaviour.
  • I have tried logging (with print statements)
  • I have tried changing the order
  • I have rewritten the code 2 times to check if anything changed.

code:

Code
local tweenservice = game:GetService("TweenService")

local RightBase = script.Parent.RightSide.RightBaseInput

--Upper right
local primarypartTop = RightBase.Upper
local infoTop        = TweenInfo.new(2, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenTop       = tweenservice:Create(primarypartTop, infoTop, {
	CFrame = RightBase.UpperRightInputOut.CFrame
})

local infoTop_        = TweenInfo.new(2, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenTop_       = tweenservice:Create(primarypartTop, infoTop_, {
	CFrame = RightBase.UpperRightInputIn.CFrame
})

-- Lower right
local primarypartLow = RightBase.Lower
local infoLow        = TweenInfo.new(2, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenLow       = tweenservice:Create(primarypartLow, infoTop, {
	CFrame = RightBase.LowerRightInputOut.CFrame
})

local infoLow_        = TweenInfo.new(2, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenLow_       = tweenservice:Create(primarypartLow, infoLow_, {
	CFrame = RightBase.LowerRightInputIn.CFrame
})

-- Right Frame
local primarypartRightFrame = RightBase.RightRightFrame.PrimaryPart
local infoRightFrame        = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenRightFrame       = tweenservice:Create(primarypartRightFrame, infoRightFrame, {
	CFrame = RightBase.RightRightFrameOpen.CFrame
})

local infoRightFrame_        = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenRightFrame_       = tweenservice:Create(primarypartRightFrame, infoRightFrame_, {
	CFrame = RightBase.RightRightFrameClosed.CFrame
})

-- Left Frame
local primarypartLeftFrame = RightBase.RightLeftFrame.PrimaryPart
local infoLeftFrame        = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenLeftFrame       = tweenservice:Create(primarypartLeftFrame, infoLeftFrame, {
	CFrame = RightBase.RightLeftFrameOpen.CFrame
})

local infoLeftFrame_        = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenLeftFrame_       = tweenservice:Create(primarypartLeftFrame, infoLeftFrame_, {
	CFrame = RightBase.RightLeftFrameClosed.CFrame
})

-- Right glass
local primarypartRightGlass = RightBase.RightRightGlass.PrimaryPart
local infoRightGlass       = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenRightGlass      = tweenservice:Create(primarypartRightGlass, infoRightGlass, {
	CFrame = RightBase.RightRightGlassMainOpen.CFrame
})

local infoRightGlass_        = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenRightGlass_       = tweenservice:Create(primarypartRightGlass, infoRightGlass_, {
	CFrame = RightBase.RightRightGlassMainClosed.CFrame
})

-- Left glass
local primarypartLeftGlass = RightBase.RightLeftGlass.PrimaryPart
local infoLeftGlass       = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenLeftGlass      = tweenservice:Create(primarypartLeftGlass, infoLeftGlass, {
	CFrame = RightBase.RightLeftGlassMainOpen.CFrame
})

local infoLeftGlass_        = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenLeftGlass_       = tweenservice:Create(primarypartLeftGlass, infoLeftGlass_, {
	CFrame = RightBase.RightLeftGlassMainClosed.CFrame
})


-- Right Hatch
local primarypartRightHatch = RightBase.Parent["Misc."].Rdoor
local infoRightHatch      = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenRightHatch     = tweenservice:Create(primarypartRightHatch, infoRightHatch, {
	CFrame = RightBase.Parent["Misc."].RdoorOpen.CFrame
})

local infoRightHatch_        = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenRightHatch_       = tweenservice:Create(primarypartRightHatch, infoRightHatch_, {
	CFrame = RightBase.Parent["Misc."].RdoorClosed.CFrame
})

-- Right Lowering
local primarypartRightLowering = RightBase.Lower
local infoRightLowering     = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenRightLowering     = tweenservice:Create(primarypartRightLowering, infoRightLowering, {
	CFrame = RightBase.LowerRightInputOutD.CFrame
})

local infoRightLowering_        = TweenInfo.new(1, Enum.EasingStyle.Quad,Enum.EasingDirection.InOut, 0, false, 0)
local tweenRightLowering_       = tweenservice:Create(primarypartRightLowering, infoRightLowering_, {
	CFrame = RightBase.LowerRightInputOut.CFrame
})

for index, instance in pairs(RightBase.Base:GetDescendants()) do 
	if instance:IsA("BasePart") then
		instance.Transparency = 1
	end
end

function vis(stat)
	for index, instance in pairs(RightBase.Base:GetDescendants()) do 
		if instance:IsA("BasePart") then
			instance.Transparency = stat
		end
	end
end

function remove(plr)
	local itemName = "Base"
	
	if plr.Backpack:FindFirstChild(itemName) and plr.Backpack[itemName]:IsA("Tool") then
		
		plr.Backpack.Cup:Destroy()
	end
	
	if plr.Character and plr.Character:FindFirstChild(itemName) and plr.Character[itemName]:IsA("Tool") then
		
		plr.Character[itemName]:Destroy()
		
	end
end

function input(plr)

	RightToggle(false)
	local humanoid = plr.Character.Humanoid
	local character = plr.Character
	local humanoid = character:FindFirstChild("Humanoid")

	local animation = RightBase.Animation
	local track = humanoid:LoadAnimation(animation)
	track.Priority = Enum.AnimationPriority.Action
	
	RightBase.prox.ProximityPrompt.Enabled = false
	humanoid.RootPart.CFrame = RightBase.AvatarSpot.CFrame
	humanoid.RootPart.Anchored = true
	
	track:play()
	
	remove(plr)
	
	wait(0.67)
	
	vis(0)
	
	humanoid.RootPart.Anchored = false

end

function RightToggle(stat)
	RightBase.prox.ProximityPrompt.Enabled = stat
end

function rightInput(plr)

	tweenRightHatch:Play()
	
	tweenRightHatch.Completed:Wait()
	
	tweenTop:Play()
	tweenLow:Play()
	
	tweenLow.Completed:Wait()
	
	primarypartLeftFrame.Anchored = true
	primarypartRightFrame.Anchored = true
	
	primarypartLeftGlass.Anchored = true
	primarypartRightGlass.Anchored = true
	
	tweenRightFrame:Play()
	tweenLeftFrame:Play()
	
	tweenLeftFrame.Completed:Wait()
	
	tweenRightGlass:Play()
	tweenLeftGlass:Play()
	
	tweenLeftGlass.Completed:Wait()
	
	tweenRightLowering:Play()
	
	tweenRightLowering.Completed:Wait()
	
	RightToggle(true)
	RightBase.prox.ProximityPrompt.Triggered:Wait()
	input(plr)
	
	RightToggle(true)
	
	tweenRightLowering_:Play()

	tweenRightLowering_.Completed:Wait()
	
	primarypartLeftFrame.Anchored = true
	primarypartRightFrame.Anchored = true

	primarypartLeftGlass.Anchored = true
	primarypartRightGlass.Anchored = true
	
	tweenRightGlass_:Play()
	tweenLeftGlass_:Play()
	
	tweenLeftGlass_.Completed:Wait()
	
	tweenRightFrame_:Play()
	tweenLeftFrame_:Play()
	
	tweenLeftFrame_.Completed:Wait()
	
	primarypartLeftFrame.Anchored = false
	primarypartRightFrame.Anchored = false

	primarypartLeftGlass.Anchored = false
	primarypartRightGlass.Anchored = false
	
	wait(1)
	tweenTop_:Play()
	tweenLow_:Play()
	
	tweenTop_.Completed:Wait()

	tweenRightHatch_:Play()
	
end

vis(1)

RightBase.prox.ProximityPrompt.Enabled = true
RightBase.prox.ProximityPrompt.Triggered:Connect(rightInput)



You seem to have two calls to the Proximity Prompts Triggered event.
Are you using the same prompt for more than one action and causing the “rightInput” function to be called twice?

1 Like

Inside the function your waiting for the triggered event and you have a listener outside the function that also listens for the event that calls the function again. The second time you use the prompt your fullfilling the wait trigger but your also calling the function a 2nd time.

1 Like

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