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

Why is this not allowing a TeamColor change? [Solved]

I have recompiled the code to match all of the fixes below, however, none have worked. Here's the current code --

script.Parent.ClickDetector.MouseClick:connect(function(hit)
	if hit:IsFriendsWith(game.CreatorId) or hit.Name == "Player1" then
		local playr = hit.Character
		playr.Torso.CFrame = CFrame.new(-182.5, 6.385, 130.5)
		print(hit.Parent)
		hit.Neutral = false
		hit.TeamColor = BrickColor.new("Really Black")
	else
		print("You're not friendly enough, ".. tostring(hit) .. "!")
	end
end)

I receive no output whatsoever, and the team won't change. Everything else in the script works 100% correctly.

Thank you for reading, and I hope to find why this won't work.

EDIT -- I just solved this. Based on the link that Merely gave me, I switched "Really Black" with the color code (1003), and it's working correctly now.

So, for anybody reading this, if a team color change isn't working, use the color code instead of the color name.

3 answers

✓ Accepted answer

The MouseClick event gives you a player object. So hit is a Player object. When you're trying to set hit.Parent.TeamColor, hit.Parent is the Players service. So you just need to be using hit.TeamColor instead.

EDIT: In addition, as pointed out by Exbryst, Very Black isn't a valid BrickColor. You should be using "Really black"

Here's a list of valid BrickColors: http://wiki.roblox.com/index.php?title=BrickColor_codes

1 comment

0

Actually, it's still not wanting to work. Whenever I click it, it teleports me but won't change my team color. I can guarantee that I've got a "Really Black" team inside of "Teams". Any idea what the issue might be?

Very Black isn't a color. The correct color would be "Really black".

2 comments

0

Oh, I must have pressed "CTRL + Z" one too many times; I could have sworn I changed that. Thanks for the notification!

0

Yes, the B in Black is lowercase in this case. It has to be the EXACT name with EXACT case.

The code was good, you just had to make the player not neutral. When a player is neutral, they can't be on any team.

script.Parent.ClickDetector.MouseClick:connect(function(hit)
    if hit:IsFriendsWith(game.CreatorId) or hit.Name == "Player1" then
        local playr = hit.Character
        playr.Torso.CFrame = CFrame.new(-182.5, 6.385, 130.5)
        print(hit.Parent)
	hit.Neutral = false --This is all I changed
        hit.TeamColor = BrickColor.new("Really black")
    else
        print("You're not friendly enough, ".. tostring(hit) .. "!")
    end
end)

2 comments

0

This looked very promising, but sadly, it still isn't working. The player is already put onto a team by default, so I'm guessing that Neutral was already false .

0

I tested this code and it does in fact work. However, you have to have the black team set to AutoAssign = false, and this code is assuming that there are no other teams with AutoAssign = true.

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