GUI tween not playing

  1. What do you want to achieve? A tween moving in the player screen’s for about a second, then moving outside of it again when you click a button.

  2. What is the issue? The tween is not playing, and I’m not receiving any error either.

  3. What solutions have you tried so far? Tried looking at the DevForum & YouTube, no solutions.

Here’s the script:

script.Parent.MouseButton1Click:Connect(function()
	game.StarterGui.ScreenGui.CollectedNotification:TweenPosition(
		UDim2.new(0.25, 0,0.02, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Linear,
		1,
		false,
		nil
	)

	task.wait(1)

	game.StarterGui.ScreenGui.CollectedNotification:TweenPosition(
		UDim2.new(0.25, 0,-0.2, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Linear,
		1,
		false,
		nil
	)
end)

Here’s what is actually happening:

Have you used tween:Create and tween:Play?

That’s not how you access the player gui, from a local script you could do it like this:

game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')

game.StarterGui.ScreenGui?

ScreenGui is not in StarterGui when game starts (starter gui is inside of the PlayerGui)

Code:

local player

game.Players.PlayerAdded:Connect(function(plr)
player = plr
end)

script.Parent.MouseButton1Click:Connect(function()
	player.PlayerGui.ScreenGui.CollectedNotification:TweenPosition(
		UDim2.new(0.25, 0,0.02, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Linear,
		1,
		false,
		nil
	)

	task.wait(1)
player.PlayerGui.ScreenGui.CollectedNotification:TweenPosition(
		UDim2.new(0.25, 0,-0.2, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Linear,
		1,
		false,
		nil
	)
end)

Or just put local script inside screen gui

Code:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.CollectedNotification:TweenPosition(
		UDim2.new(0.25, 0,0.02, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Linear,
		1,
		false,
		nil
	)

	task.wait(1)
script.Parent.CollectedNotification:TweenPosition(
		UDim2.new(0.25, 0,-0.2, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Linear,
		1,
		false,
		nil
	)
end)

When using that, it gives an error and doesn’t work still. The localscript is parented to the StarterGui.
image

1 Like

Put TextButton inside of the screen gui named “Button” and then.

Code:

script.Parent.Button.MouseButton1Click:Connect(function()
	script.Parent.CollectedNotification:TweenPosition(
		UDim2.new(0.25, 0,0.02, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Linear,
		1,
		false,
		nil
	)

	task.wait(1)
script.Parent.CollectedNotification:TweenPosition(
		UDim2.new(0.25, 0,-0.2, 0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Linear,
		1,
		false,
		nil
	)
end)
1 Like

Works after modifying it to my button’s name, thanks!

1 Like