Hey there! I have a simple question: how do I cancel a tween made by the TweenService? Here is an example of where I may implement this:
local tween = TweenService:Create(
someObject,
TweenInfo.new(1),
{
Position = Vector3.new(0, 0, 0)
}
)
tween:Play()
somethingHappenedWhichNeedsToStopTheTweenEvent.OnClientEvent:Connect(function ()
-- stop the tween but leave is where it is and do not remove it's progress
end)
I am aware of a similar question (How can I stop my tween?), but that answers how to stop a GUI implemented tween. I am unable to find an answer to my question which is stopping a tween constructed from the TweenService.
tween:Pause() is probably what you’re looking for.
It just takes a simple google search to find this. If you don’t know - the API for everything Roblox is available online at the Developer Hub. Here is the page for Tween.
somethingHappenedWhichNeedsToStopTheTweenEvent.OnClientEvent:Connect(function ()
if tween.PlaybackState == Enum.PlaybackState.Playing then
tween:Pause()
end
end)