Player Highlight color not changing to team color

  1. What do you want to achieve? Keep it simple and clear!

I added a highlight to StarterCharacterScripts, but I want the color of the highlight to change to the team color that the player is on.

  1. What is the issue? Include screenshots / videos if possible!

The outline color doesn’t change at all.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried looking around and didn’t find anyone with the same issue. I Used the print function to test and it still printed.

Current code
wait(3)
local outlinec = script.Parent.OutlineColor
local team = game:GetService("Players").LocalPlayer.TeamColor.Color

outlinec = team

print("working?")

change outlinec to

outlinec.FillColor = team

assuming that outlinec is a Highlight

Also kinda a preference but I’d like to organize your code a bit

local Player = game.Players.LocalPlayer

script.Parent.OutlineColor.FillColor = Player.Team.Color

The reason I didn’t set a variable for OutlineColor and Team is because it seems like you’re only gonna be using it once. You don’t have to sue this but I just thought that I should fix / clean it up a bit for you.

But with the player, you might use it for other purposes if this LocalScript will contain other code so yeah

So outlinec is the highlight’s outline color. I want to change the outline color, not the fill color. The script I posted isn’t changing the color, but it’s still printing the print function i put in it.

1 Like

mb alr so I guess you’d just do this:

script.Parent.OutlineColor = team

don’t save OutlineColor to a variable, if you want a explanation I can provide it

1 Like

would you like an explanation?

It worked, can you explain why it worked when not saved to a variable?

Yes, could you explain? also, do you have any ideas how I could make this server side so every player can see the color? If not I can figure it out.

1 Like

Alr so when you’re doing this:

local outlinec = …

You’re actually saving the current color of the Highlight. You’re not referencing the OutlineColor property.

So when you did this:

outlinec = team

The (compiler) was reading this:

White = team

More in depth if you understood the above:

Basically, when you were assigning script.Parent.OutlineColor, you thought that the variable would be holding a reference to the OutlineColor property.

But instead, it was actually just holding the value of the OutlineColor property.

Only when you’re assigning a new value to the property (without the use of a variable referencing the property) will it actually be referencing the property.

An example of this could be the Team color, your saving the value of the Team color to ”team” to a variable and when you used it, it changed the color to the Team’s color right?

Yeah, but if you try to change it, you’d assign it (with =) and it would be referencing like this;

team = color

instead of

Blue = color
1 Like

You’d just connect this to the player added event

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
   Player.CharacterAdded:Connect(function(Character)
      -- do your cloning stuff here
   end)
end)

basically every time a new player joins, the PlayerAdded event will fire and then all you gotta do is just do the cloning and assigning on the server

I’d recommend you keep the highlight in ReplicatedStorage and ya just clone the highlight and parent it to the player

1 Like

This worked perfectly, thx so much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.