Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
RoboFrog 400 Moderation Voter
10 years ago

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

Log in to vote
3
Answered by
Merely 2122 Moderation Voter Community Moderator
10 years ago

The MouseClick event gives you a player object. So hitis 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

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? RoboFrog 400 — 10y
Ad
Log in to vote
3
Answered by 10 years ago

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

0
Oh, I must have pressed "CTRL + Z" one too many times; I could have sworn I changed that. Thanks for the notification! RoboFrog 400 — 10y
0
Yes, the B in Black is lowercase in this case. It has to be the EXACT name with EXACT case. Tkdriverx 514 — 10y
Log in to vote
1
Answered by 10 years ago

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)
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 . RoboFrog 400 — 10y
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. User#348 0 — 10y

Answer this question