ImageButton.Activated Not Firing?

At the bottem where it says script.Parent.PlayScreen.Play.Activated:Connect(function()
for some reason it dosent fire when the player clicks on the button and I cant seem to figure out why.

local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local ContentProvider = game:GetService("ContentProvider")

local Player = Players.LocalPlayer
local PlayerGui = Player.PlayerGui

script.Parent.Parent = PlayerGui

local LoadingMusic = script.Parent.LoadingMusic
LoadingMusic:Play()

local PreloadAssets = {
	"rbxassetid://1839830753",
	"rbxassetid://1836098756"
}

local ContentProvider = game:GetService("ContentProvider")
ContentProvider:PreloadAsync(PreloadAssets)

ReplicatedFirst:RemoveDefaultLoadingScreen()
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)

task.wait(10)  -- Force screen to appear for a minimum number of seconds
if not game:IsLoaded() then
	game.Loaded:Wait()
end

for i = 0, 1, .02 do
	script.Parent.LoadingText.Transparency = i
	script.Parent.LoadingInfo.Transparency = i
	task.wait()
end

script.Parent.LoadingText.Transparency = 1
script.Parent.LoadingInfo.Transparency = 1

local IntroMusic = script.Parent.IntroMusic

local TweenService = game:GetService("TweenService")
local FadeTweenA = TweenService:Create(script.Parent.Frame1.Frame2, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, false, 0), {BackgroundColor3 = Color3.new(1, 1, 1)})
local FadeTweenB = TweenService:Create(LoadingMusic, TweenInfo.new(3, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, false, 0), {Volume = 0})
local FadeTweenC = TweenService:Create(IntroMusic, TweenInfo.new(3, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, false, 0), {Volume = 0.5})

local PlayScreenTween = TweenService:Create(script.Parent.PlayScreen, TweenInfo.new(3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {Position = UDim2.new(0.5, 0, 0.5, 0)})

local GH = script.Parent
local CCY = GH.Frame1.Frame2.Centre.Yellow
local CCO = GH.Frame1.Frame2.Centre.Blue
local CCR = GH.Frame1.Frame2.Centre.Red
local CCG = GH.Frame1.Frame2.Centre.Purple
local LIFU = GH.Frame1.Linefu
local LIFU2 = GH.Frame1.Linefu2
local FR3 = GH.Frame1.Frame3
local BO = GH.Frame1.Bordershade
local Logo = GH.Frame1.Frame2.Centre.Logo
local LB = Logo.Parent.LogoB
local TT = 1

--Turning off other guis--

local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable

--Music--
FadeTweenB:Play()
task.wait(1.5)
FadeTweenA:Play()
IntroMusic:Play()
FadeTweenC:Play()
FadeTweenC.Completed:Wait()
LoadingMusic:Stop()

CCY:TweenSize(UDim2.new(0, 100, 0, 100), "Out", "Quad", .5)
task.wait(TT)
CCO:TweenSize(UDim2.new(0, 100, 0, 100), "Out", "Quad", .5)
task.wait(TT)
CCR:TweenSize(UDim2.new(0, -100, 0, 100), "Out", "Quad", .5)
task.wait(TT)
CCG:TweenSize(UDim2.new(0, 100, 0, -100), "Out", "Quad", .5)
task.wait(2)
LIFU:TweenSize(UDim2.new(-2, 0, 0, 200), "Out", "Quad", 1)
LIFU2:TweenSize(UDim2.new(2, 0, 0, 200), "Out", "Quad", 1)
task.wait(.2)
CCY.Visible = false
CCO.Visible = false
CCR.Visible = false
CCG.Visible = false
task.wait(.8)
LIFU:TweenSize(UDim2.new(0, 0, 0, 200), "Out", "Quad", 1)
LIFU2:TweenSize(UDim2.new(0, 0, 0, 200), "Out", "Quad", 1)
task.wait(.25)
Logo.Visible = true
task.wait(1.64)
Logo:TweenSizeAndPosition(UDim2.new(1, 0, 1, 0), UDim2.new(0, 0, 0, 0), "Out", "Quad", .3)
LB:TweenSizeAndPosition(UDim2.new(1, 0, 1, 0), UDim2.new(0, 0, 0, 0), "Out", "Quad", .3)
task.wait(3)
GH.Frame1.Linefu.Visible = false
GH.Frame1.Linefu2.Visible = false
GH.Frame1.Bordershade.Visible = false

Camera.CFrame = CFrame.new(-544.575317, 6280.03516, 2138.18726, 0.820768833, -0.370405495, -0.434900403, -2.98023224e-08, 0.76129961, -0.648400307, 0.571260571, 0.532186747, 0.624850929)

task.wait(1)
for i = 0, 1, .02 do
	GH.Frame1.BackgroundTransparency = i
	Logo.ImageTransparency = i
	LB.ImageTransparency = 1 - i
	FR3.Parent.Frame2.BackgroundTransparency = i
	task.wait()
end

Logo.Visible = false

for i = 0, 1, .02 do
	LB.ImageTransparency = i
	BO.ImageTransparency = i
	task.wait()
end

LB.Visible = false

local Tween = TweenService:Create(Camera, TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {CFrame = CFrame.new(1261.276, 157.193787, -284.975464, 0.784922183, -0.0783377662, 0.614622176, -0, 0.991975069, 0.126433954, -0.619594395, -0.0992408171, 0.778623164)})
local TweenB = TweenService:Create(Camera, TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {Focus = CFrame.new(1260.04675, 156.940918, -286.532715, 1, 0, 0, 0, 1, 0, 0, 0, 1)})
Tween:Play()
TweenB:Play()
Tween.Completed:Wait()
task.wait(1)

local Blur = script.Blur
Blur.Parent = Camera

TweenService:Create(Blur, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {Size = 25}):Play()
task.wait(1)
PlayScreenTween:Play()
print("Im Here")
script.Parent.PlayScreen.Play.Activated:Connect(function()
	print("Clicked")
	for i = 0, 1, .02 do
		script.Parent.PlayScreen.Fade.Transparency = 1 - i
		task.wait()
	end

	for i = 0, 0.5, .02 do
		IntroMusic.Volume = 0.45 - i
		task.wait()
	end

	task.wait(0.5)

	Camera.CameraType = Enum.CameraType.Custom

	script.Parent.PlayScreen.Play:Destroy()
	script.Parent.PlayScreen.Title:Destroy()

	game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
	game.ReplicatedStorage.IntroFinished:FireServer()

	for i = 0, 1, .02 do
		script.Parent.PlayScreen.Fade.Transparency = i
		task.wait()
	end

	game.ReplicatedStorage.StartAmbience:Fire(true)

	Blur:Destroy()
	script.Parent:Destroy()
end)
print("Connected")

Hello!
You can try to use script.Parent.PlayScreen.Play.MouseButton1Click:Connect(function(),
In this case if you want to run a function you should use MouseButton1Click event.

Make sure there isn’t another UI element blocking the button you’re trying to click.

1 Like

.Activated doesn’t function the way you think it does. Use MouseButton1Click for button activation.