Script not playing the functions

the script isn’t playing all of the functions demanded. I’ve tried lots of solutions but none of them work
they don’t play all together

here’s the script:

local part = script.Parent.Parent
local attachment = part.Attachment
local tweenService = game:GetService("TweenService")

local function rotatePart()
	tweenService:Create(part, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {CFrame = part.CFrame * CFrame.Angles(math.rad(90), 0, 0)}):Play()
end

local function movePart()
	tweenService:Create(part, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Position = Vector3.new(7, 2.659, 23.39)}):Play()
end

local function moveTool()
	tweenService:Create(attachment, TweenInfo.new(3, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Position = Vector3.new(7.015, 0.674, 22.38)}):Play()
end

script.Parent.Triggered:Connect(function()
	rotatePart()
	movePart()
	moveTool()
end)

I’m not understanding, are they not running? Or are they running at different times? Are certain ones working and others not?
I ran a simple test and I could get multiple tweens to run simultaneously even on the same part

this video should help:

External Media

Try making the rotatePart() function not use CFrame or combining the rotatePart and movePart functions into one tween

local part = script.Parent.Parent
local attachment = part.Attachment
local tweenService = game:GetService("TweenService")

local function rotatePart()
	tweenService:Create(part, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Orientation = part.Orientation + Vector3.new(90, 0, 0)}):Play()
end

local function movePart()
	tweenService:Create(part, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Position = Vector3.new(7, 2.659, 23.39)}):Play()
end

local function moveTool()
	tweenService:Create(attachment, TweenInfo.new(3, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Position = Vector3.new(7.015, 0.674, 22.38)}):Play()
end

script.Parent.Triggered:Connect(function()
	rotatePart()
	movePart()
	moveTool()
end)
1 Like

Try replacing your functions with the following:

local function rotatePart()
	spawn(function() tweenService:Create(part, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {CFrame = part.CFrame * CFrame.Angles(math.rad(90), 0, 0)}):Play(); end)
end

local function movePart()
	spawn(function() tweenService:Create(part, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Position = Vector3.new(7, 2.659, 23.39)}):Play(); end)
end

local function moveTool()
	spawn(function() tweenService:Create(attachment, TweenInfo.new(3, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Position = Vector3.new(7.015, 0.674, 22.38)}):Play(); end)
end

This should allow the tweens to be played simultaneously. I know using spawn(callback) is not necessarily the best practice, but it does in fact save some line usage!

1 Like

this worked! thank you so much! and @Gyromus GameSaviour, ive tried that method a couple a minutes ago but it didn’t work for some reason… :thinking: but thanks for everyone participating.

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