GUI animation not running on click

Hey everyone! So today I was practicing with GUI tweening, I wanted to make it so when the Player clicks play on the TextButton, the button slides to the left, I tested it out with no errors and I clicked on it and nothing happened, does anyone know why? Here is my script…

 local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
character:WaitForChild("HumanoidRootPart").Anchored = true

local TweenService = game:GetService("TweenService")

repeat wait()
	   Camera.CameraType = Enum.CameraType.Scriptable
	until Camera.CameraType == Enum.CameraType.Scriptable 
Camera.CFrame = workspace.Camerapart.CFrame

local info = TweenInfo.new(20,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local rotating = true

while rotating do
	local cameraTween = TweenService:Create(Camera,info, {CFrame = Camera.CFrame * CFrame.fromEulerAnglesXYZ(0, 360, 0);})
	cameraTween:Play()
	local blur = Instance.new("BlurEffect")
	blur.Parent = workspace.CurrentCamera
	blur.Enabled = true
	blur.Size = 10
	wait(0.02)
end

local MainMenu = script.Parent

local PlayButton = MainMenu:WaitForChild("TextButton")

local pT = PlayButton:TweenPosition(UDim2.new({-0.2, 0},{0.725, 0}))

local tween = TweenService:Create(PlayButton,info,pT)

PlayButton.MouseButton1Click:Connect(function()
	tween:Play()
	
	wait(3)
	
	character.HumanoidRootPart.Anchored = false
	character.HumanoidRootPart.CFrame = workspace.SpawnPart.CFrame
	
	Camera.CameraType = Enum.CameraType.Custom
	
	MainMenu:Destroy()
end)

The script will never run beyond the while loop

1 Like

Add a break in this so the while loop will stop.

Will that make the tween work?

OH, I get it nowwwwww. let me try it out

I don’t really see the point of the while loop, a simple tween would’ve worked. But, add the break at the end of the while loop.

Oh, it’s because i’m having the camera spin in the menu.

It is fixed now, but without me even clicking on the button the tween plays and it goes to a random position that I didn’t pick. (I’m still new to scripting, so sorry for the obvious mistakes.)

Which tween are you talking about?

UDim2.new accepts 4 arguments not 2 tables

1 Like

Ok, so I got it working, now I just need to figure out how to fix this error.

--20:12:44.069 - MouseButton01Click is not a valid member of TextButton "Players.NotMookit.PlayerGui.MainMenu.TextButton"

do you know how to fix this?

Delete the 0 from the thing
It should be MouseButton1Click

Yeah, I keep forgetting things, there are no errors but when I click the button, the tween doesn’t play at all.