How do i stop a section in a script

did you try his script. It should work i tried it and dont forget to change mousehover to MouseEntered

1 Like

It could be like this:

local stop = false
script.Parent.MouseEnter:Connect(function()
	if stop == false then
		stop = true
		script.Parent:TweenPosition(script.Parent.Position + UDim2.new(0,10,0,0), "Out", "Sine", 1)
		task.wait(1)
		stop = false
	end
end)
script.Parent.MouseLeave:Connect(function()
	if stop == false then
		stop = true
		script.Parent:TweenPosition(script.Parent.Position + UDim2.new(0,-10,0,0), "Out", "Sine", 1)
		task.wait(1)
		stop = false
	end
end)

it doesn’t work sadly. empty space.

wait what do i put in

for

do i make it

local info = script.Parent:TweenInfo.new(script.Parent.Position + UDmin.new(0,-10,0,0), "Out", "Sine", 1)

Are you missing something? Because script should work properly. Are you sure putting script into local script?

You wrote the complete script false i will send u a script now

The script must be right at least mine, which i got from you, because it works properly. Everything right

Heres a completely different system, but it should work.

local StartPos = script.Parent.Position

local Hover = false
script.Parent.MouseEnter:Connect(function()
	Hover = true
end)
script.Parent.MouseLeave:Connect(function()
	Hover = false
end)

local RunService  = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
	if Hover then
		script.Parent:TweenPosition(StartPos + UDim2.new(0,10,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 1, false)
	else
		script.Parent:TweenPosition(StartPos, Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 1, false)
	end
end)

(I put the effort in to test this, if it doesnt work then maybe one of your scripts is intervening.)

local stop = false
local enterOrLeave = false

script.Parent.MouseEnter:Connect(function()

	if stop == false then
		stop = true
		
		if enterOrLeave == false then
			
			script.Parent:TweenPosition(script.Parent.Position + UDim2.new(0,10,0,0), "Out", "Sine", 1, true, function()
				
				enterOrLeave = true
				stop = false
				
			end)
			
		elseif enterOrLeave == true then
			
			script.Parent:TweenPosition(script.Parent.Position + UDim2.new(0,-10,0,0), "Out", "Sine", 1, true, function()
				
				enterOrLeave = false
				stop = false
				
		end)

			
			end
	end
end)

This will work. Tested.

This solution isnt reliable because it adds to the current position. In my solution I add to the initial position. my solution prevents an error for example if lag happens causing a possible error in the tween and thus putting it off course which is what OP intends to not do.

No, u cant again MouseEnter until the Tween is completly ended. Or what do you mean i dont know If it laggs u also cant MouseEnter again until the Tween is finished

If you haven’t found a solution yet, try this:

local position = script.Parent.Position 

script.Parent.MouseEnter:Connect(function()
    script.Parent:TweenPosition(position + UDim2.new(0, 10, 0, 0), "Out", "Sine", 1)
end)

script.Parent.MouseLeave:Connect(function()
    script.Parent:TweenPosition(position, "Out", "Sine", 1)
end)

That is not the Question he have but he taked the script what is not working good as the Result.