Doesn't see the button

local teams = {
	game.Teams["Factory 1"],
	game.Teams["Factory 2"],
	game.Teams["Factory 3"],
	game.Teams["Factory 4"],
	game.Teams["Factory 5"],
	game.Teams["Factory 6"]
}

local batton = game:WaitForChild("StarterGui").MainMenu.PlayButton
print("sdfsdf")
gam = game:GetService("Players")

batton.MouseButton1Click:Connect(function(plr)
	print("dfdfg")
end)

Hello. An unknown problem occurs. The path to the button is laid out normally. I don’t know why the function is not being processed.

1 Like

wdym by that? and also maybe you can try batton.Visible = true

1 Like

StarterGui is different from the one the player sees on the screen, it is in PlayerGui (child of player) and cloned from StarterGui. Replace that this instead (make sure its a local script):

local player = game.Players.LocalPlayer
local batton = player.PlayerGui.MainMenu.PlayButton

I did it but the function doesn’t work. no print

is that a localscript or server script?

  1. I’m not sure if its related to your issue but MouseButton1Click doesn’t return a player
  1. Make sure that your Gui is actually a TextButton or ImageButton
  2. Like @neweve2323 said, you can’t use StarterGui. You have to go into the player’s gui instead.

Put a local script inside of your text button and change the script to something like this:

local gam = game:GetService("Players")
local batton = script.Parent
print("sdfsdf")

batton.MouseButton1Click:Connect(function()
	print("button clicked")
	--I'm guessing you have to change a player's team through a server script so
	--just put a remote event here.
end)

use
local gam = game:GetService("Players")

that a localscript. but it must be server-based

Everything works, thanks guys.