How do I stop an Action while its happening! [Properties]

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    • So lets say you had a Menu like I do, And there are few buttons that you want to Animate [kinda], so if you haver your mouse or hold your finger on the button! It will hmm, make it less Transparent! And if you let your finger go or Move your mouse away from the button, the Transparency rises! Watch this video:
  1. What is the issue? Include screenshots / videos if possible!

    Its probably very laggy or doesn’t even work! Sorry if it does/doesn’t! Tell me and I’ll try and fix it or post the video on other platforms!
  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    • I honestly have no clue what to search, if someone else had the same issue as me they might take a while to find this topic as well…
      After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
    • So what I used is TweenService but it doesnt fix the problem unfortunately, Nor does a for loop! I wanted to check If statements every
      few seconds to see if the mouse is still there but that would take s o o long! Is this even possible? Please help I always wanted to know!
-- Thanks for stopping by!

Edit: A the slightly laggy video doesn’t really show what its like! Sorry! But I hope you get the idea!
Edit2: WOW I was right… It does take forever for people to find this topic!- :shock:

1 Like

A simple fix is to disable all of the other scripts while the player is hovering over a singular button.

Example:
While the player is hovering over Chapter II,
You can add this to the Chapter II button script under the mouse hover function:

script.Parent.Parent.Chapter2.LocalScript.Disabled = true

@oscoolerreborn can you send a screenshot of your explorer tab with the the text button’s scripts showing?

Explorer:


A don’t judge me ;-;
Script:

local ChapterNumber = 1

local Object = script.Parent.Parent:WaitForChild("GradientChapter"..ChapterNumber)

StartingTransparency = 0.6

local TweenService = game:GetService("TweenService")

local InformatioNTween = TweenInfo.new(

.5,

Enum.EasingStyle.Linear,

Enum.EasingDirection.In,

0,

false,

0

)

local InformationTableValues = {

BackgroundTransparency = StartingTransparency

}

TweenServiceCreateUnTransparent = TweenService:Create(Object,InformatioNTween,InformationTableValues)

script.Parent.MouseEnter:Connect(function()

if script.Parent.Parent.Parent:WaitForChild("TweenServiceCanContinue").Value then

TweenServiceCreateUnTransparent:Play()

end

end)

local InfoTweenService = TweenInfo.new(

0.5,

Enum.EasingStyle.Linear,

Enum.EasingDirection.Out,

0,

false,

0

)

local TableProperty = {

Transparency = 0.8

}

local CreateTweenTransparent = TweenService:Create(Object,InfoTweenService,TableProperty)

script.Parent.MouseLeave:Connect(function()

if script.Parent.Parent.Parent:WaitForChild("TweenServiceCanContinue").Value then

CreateTweenTransparent:Play()

end

end)

See the first variable? All the scripts in the EXPLORER that go by the name Chapter[1,2,3,4,5,6]Script Are the same but with a different variable [First line] :slightly_smiling_face:

also

if script.Parent.Parent.Parent:WaitForChild("TweenServiceCanContinue").Value then
end

is just a Value i set every time so the tween can continue :smiley: like you said but different 0:!
[im having deja vu aaa]

Ok, try this:

local ChapterNumber = 1

local Object = script.Parent.Parent:WaitForChild("GradientChapter"..ChapterNumber)

StartingTransparency = 0.6

local TweenService = game:GetService("TweenService")

local InformatioNTween = TweenInfo.new(

.5,

Enum.EasingStyle.Linear,

Enum.EasingDirection.In,

0,

false,

0

)

local InformationTableValues = {

BackgroundTransparency = StartingTransparency

}

TweenServiceCreateUnTransparent = TweenService:Create(Object,InformatioNTween,InformationTableValues)

script.Parent.MouseEnter:Connect(function()

if script.Parent.Parent.Parent:WaitForChild("TweenServiceCanContinue").Value then

TweenServiceCreateUnTransparent:Play()

script.Parent.Parent.Chapter2.Chapter2Script.Disabled = true

script.Parent.Parent.Chapter3.Chapter3Script.Disabled = true

script.Parent.Parent.Chapter4.Chapter4Script.Disabled = true

script.Parent.Parent.Chapter5.Chapter5Script.Disabled = true

script.Parent.Parent.Chapter6.Chapter6Script.Disabled = true

end

end)

local InfoTweenService = TweenInfo.new(

0.5,

Enum.EasingStyle.Linear,

Enum.EasingDirection.Out,

0,

false,

0

)

local TableProperty = {

Transparency = 0.8

}

local CreateTweenTransparent = TweenService:Create(Object,InfoTweenService,TableProperty)

script.Parent.MouseLeave:Connect(function()

if script.Parent.Parent.Parent:WaitForChild("TweenServiceCanContinue").Value then

CreateTweenTransparent:Play()

script.Parent.Parent.Chapter2.Chapter2Script.Disabled = false

script.Parent.Parent.Chapter3.Chapter3Script.Disabled = false

script.Parent.Parent.Chapter4.Chapter4Script.Disabled = false

script.Parent.Parent.Chapter5.Chapter5Script.Disabled = false

script.Parent.Parent.Chapter6.Chapter6Script.Disabled = false

end

end)

Sorry for the mess but I am currently on mobile and I have to go to work soon.

Don’t worry its fine, good luck at work by the way, also
this was a huge mess and unfortunately it still doesn’t work! Still looks fine!
Thanks for the help! Here is a video showing it: a prepare to be traumatized by script!


Im not even sure that is the righ video but There you go! :slightly_smiling_face:

Read after watching!

Did you just watch a whole video of me just moving my mouse…? wow!

OHHHHHHHH i forgot something in the script aaaa brb i fix it!
AAAAAAAAAA it doesn’t work

I think it would more be cleaner and less redundant to just loop over your text buttons and tween them upon MouseEnter and MouseLeave. Something like this:

local tween
for _, textButtons in pairs(frame:GetChildren()) do  -- frame being the parent container
	if textButtons:IsA('TextButton') then
		textButtons.MouseEnter:Connect(function()
			tween = tweenService:Create(textButtons, InformatioNTween , {BackgroundTransparency = .8})
			tween:Play()
		end)
		textButtons.MouseLeave:Connect(function()
			tween = tweenService:Create(textButtons, InformatioNTween , {BackgroundTransparency = .6})
			tween:Play()
		end)
	end
end

Good Point! Thanks for the tip now I will try that ;-; :frowning_face_with_open_mouth: Lemme just implement it first…
Also I have an idea but first… Does Tween come with :Stop() or :Pause() like sounds do? :slightly_smiling_face:?

Just realized my idea would never work :(

Yeah. It has Cancel, Pause and Play, where Stop() is basically cancel here. For more information, look into its API. Also sidenote, looking into your explorer I notice that you have a local script in each button which I definitely don’t recommend. That can really be packed into one script which just makes it a lot more organised, easier for yourself to work with and easier for other to read/ work with your scripts.

1 Like

Do you know of any other way to achieve this? I really want to know a simpler way this seems… complicated ;[

I found the solution: simplified:

UI.MouseEnter:Connect(function()
    OtherTween:Cancel()
    Tween:Play()
end)
UI.MouseLeave:Connect(function()
    Tween:Cancel()
    OtherTween:Play()
end)

Thanks for the help everyone!
[Hope this helps someone else]!