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’m not sure if its related to your issue but MouseButton1Click doesn’t return a player
Make sure that your Gui is actually a TextButton or ImageButton
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)