Attempt to index nil with 'Team'

  1. What do you want to achieve?
    I am trying to make it so when the player presses the Play button on my Menu GUI they go from the team Lobby to Playing.

  2. What is the issue?
    When the player presses the Play button they do not change to the Playing team and stay on the Lobby team with the current script that I am using.
    There isnt any error from it in Output.

  3. What solutions have you tried so far?
    I tried putting the code below into its own script which also did not work.
    When trying this solution I recieve this error in Output.

Here is the code that I tried using.

script.Parent.MouseButton1Click:Connect(function(player)
	player.Team = game.Teams.Playing
	print("Team set to Playing")
end)

Here is the full script.

local TweenService = game:GetService("TweenService")
local TweenSpeed = 1
local Info = TweenInfo.new(TweenSpeed, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
local load = script.Parent.Parent.Parent.Parent.LoadingGui

script.Parent.MouseButton1Click:Connect(function(player)
	player.Team = game.Teams.Playing
	print("Team set to Playing")
end)

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Play.PlayScript.Disabled = true
	script.Parent.Parent.Rules.PopupScript.Disabled = true
	script.Parent.Parent.Settings.PopupScript.Disabled = true
	script.Parent.Parent.Shop.PopupScript.Disabled = true
	script.Parent.Parent.News.PopupScript.Disabled = true
	script.Parent.Parent.Credits.PopupScript.Disabled = true
	
	TweenService:Create(load.MainFrame, Info, {BackgroundTransparency = 0}):Play()
	TweenService:Create(load.MainFrame.Image, Info, {ImageTransparency = 0}):Play()
	TweenService:Create(load.MainFrame.TextLabel, Info, {TextTransparency = 0}):Play()
	TweenService:Create(load.MainFrame.BarHold, Info, {BackgroundTransparency = 0}):Play()
	TweenService:Create(load.MainFrame.BarHold.Bar, Info, {BackgroundTransparency = 0}):Play()
	
	load.Preload.Disabled = false
end)
1 Like

This is because this isn’t a ClickDetector, but a TextButton, and in that, it doesnt work like it does with clickdetectors.

You’d have to use a remote , from the client to the server to change the player team.

1 Like

I appreciate your help.
Any idea on how I could go about doing this? Im not too good with RemoteEvents

local script

local remoteEvent = --location of the remote event

script.Parent.MouseButton1Click:Connect(function()
	remoteEvent:FireServer()
end)

server script

local remoteEvent = -- the location of the remote event

remoteEvent.OnServerEvent:Connect(function(player)
    player.Team = game.Teams.Playing
    print(player.Name.." Team is set to playing")
end)
1 Like