TweenService not working

I created a tween so that when a player clicks the quick play button, the main menu will tween out of the screen. However, when the button is clicked, nothing happens. Anyone know how to fix this? Thanks!

Script:

local player = game:GetService("Players").LocalPlayer
local TweenService = game:GetService("TweenService")
local mainMenuFrame = player.PlayerGui:WaitForChild("MainMenu")
local TweenInformation = TweenInfo.new(1, Enum.EasingStyle.Linear)

local goal = {
	Position = UDim2.new(0, -50, 0, 75)
}

local goal2 = {
	Position = UDim2.new(0, 50, 0, 75)
}

local playTween = TweenService:Create(mainMenuFrame, TweenInformation, goal)

mainMenuFrame.QuickPlay.ClickDetector.MouseClick:Connect(function()
	playTween:Play()
end)

Workspace:
image

1 Like

can you show the video please?

You don’t need and can’t use ClickDetector, it’s only for parts, you have ImageButton and use MouseButton1Click

mainMenuFrame.QuickPlay.MouseButton1Click:Connect(function()
	playTween:Play()
end)
1 Like

YouTube video link: Auda Roblox Studio 2023 04 29 20 01 17 - YouTube

1 Like

I’ve replaced MouseButton with MouseButton1Click, although it still seems to not work. Same result as in the video: Auda Roblox Studio 2023 04 29 20 01 17 - YouTube

Perhaps you entered the position incorrectly?

1 Like

Your ‘mainMenuFrame’ variable refers to the ScreenGui, not the frame. Also just use .Activated for gui buttons. Hopefully this works:

local player = game:GetService("Players").LocalPlayer
local TweenService = game:GetService("TweenService")
local mainMenuFrame = player.PlayerGui:WaitForChild("MainMenu").MenuFrame
local TweenInformation = TweenInfo.new(1, Enum.EasingStyle.Linear)

local goal = {
	Position = UDim2.new(0, -50, 0, 75)
}

local goal2 = {
	Position = UDim2.new(0, 50, 0, 75)
}

local playTween = TweenService:Create(mainMenuFrame, TweenInformation, goal)

mainMenuFrame.QuickPlay.Activated:Connect(function()
	playTween:Play()
end)
2 Likes

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