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.
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
Very Black isn't a color. The correct color would be "Really black".
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)