Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my script with TeamColor of player in a function do nothing?

Hello everyone I'm trying to figure out why my script isn't working. I don't get an error message, but it doesn't matter. I put my script in the ServerScriptService. Could you tell me why?

My script:

game.Players.PlayerAdded:Connect(function(player)
	if player.TeamColor == game.Teams.Criminal.TeamColor then
		print("Criminal !")
	end
end)

Thanks in advance !

1 comment

0

Your code should work. Check that AutoAssignable is checked on the Criminal team object in the explorer.

2 answers

The reason your code is not working is because you didn't use the name of the TeamColor. You also didn't make a variable for "player." Also, the function isn't needed. It most likely breaks the script. I suggest using a variable if you want to do it that way, like this:

local TeamColor = game.Teams.Criminal.TeamColor
local Player = game.Players.LocalPlayer
if Player.TeamColor == TeamColor then
print("Criminal!")
end

1 comment

0

It doesn't works, as soon as I change teams, it normally displays "Criminal!", but nothing there.

Try this:

local Player = game.Players.LocalPlayer
if Player.TeamColor == "Neon orange" then
print("Criminal!")
end

But make sure the criminal's team color is Neon orange (you can change it).

Hope this helps if it works.

1 comment

0

It doesn't work either, now I even get an error message: attempt to index local 'Player' (a nil value). Why ?

This discussion is preserved as it was. New answers, comments, and votes are closed.