Print script error

I’m trying to make script that prints his name and word if player failed to change his team using button. Heres the script:

script.Parent.MouseButton1Click:Connect(function()
	if game.Players.LocalPlayer.Team = "Loading" then
		print((plr.Name), "failed to change his team to Citizen")
	end
end)
1 Like

You used an if statement with one “=” isntead of two “==”

Thats how script now looks like but when I press the button it dont print what I need.
4yuiTHE

Put an else statement to print something else, i want to check something

Can you show us where “plr” is declared

1 Like
script.Parent.MouseButton1Click:Connect(function()
	if game.Players.LocalPlayer.Team == "Loading" then
		print((plr.Name), "failed to change his team to Citizen")
	end
end)

thats how all script looks like

You never defined “plr” I can see in your image that it is underlined in orange

it is but i dont know how to fix it :confused:

No, your script starts in line 1 and you never defined “plr”

oh, now I got it, now it should work testing time

script.Parent.MouseButton1Click:Connect(function()
   local player = game.Players.LocalPlayer
   if player.Team == "Loading" then
      print(player.Name.." has failed to change his team to Citizen")
   end
end)

This might work.

Team is an instance i think.
try this instead:

game.Players.LocalPlayer.Team.Name == "Loading"

(would help alot if you can show us the error that popped up for you)!

1 Like

^
You can also use TeamColor instead of team.

script.Parent.MouseButton1Click:Connect(function()
   local player = game.Players.LocalPlayer
   local notTeamColor = Color3.fromRGB(255,255,255)
   if player.TeamColor == Color3.fromRGB(notTeamColor) then
      print(player.Name.." has failed to change his team to Citizen")
   end
end)
1 Like

no one script is working bruh… =c

What’s the error? Could you show us please?

Explorer:
RjM8pz2

idk in what problem im not very good scripter :huh:

Tip: Do not put spaces between words in naming.

Check the output. That may have something in it.

all scripts:

-- print script
script.Parent.MouseButton1Click:Connect(function()
	local player = game.Players.LocalPlayer
	local notTeamColor = Color3.fromRGB(255,255,255)
	if player.TeamColor == Color3.fromRGB(notTeamColor) then
		print(player.Name.." has failed to change his team to Citizen")
	end
end)
-- scripts in combine unit and citizen is same (LocalScript)
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer(script.Parent.Text) -- it changes player team and rank
game.Players.LocalPlayer.Character.Humanoid.Health = 0
end)
-- leaderstats script
game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder", player)
	leaderstats.Name = "leaderstats"

	local Rank = Instance.new("StringValue", leaderstats)
	Rank.Name = "Rank"
	Rank.Value = "-"

	player.Team = game.Teams.Loading
end)
-- event script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, rank)
	if typeof(rank) == "string" then
		if rank == "Combine Unit" then
			player.leaderstats.Rank.Value = "Recruit"
			player.Team = game.Teams["Combine Unit"]
		elseif rank == "Citizen" then
			player.leaderstats.Rank.Value = "Citizen"
			player.Team = game.Teams["Citizen"]
	end
	else
	print("["..rank.."] Is not a String")
end
end)