I am trying to make a part that if it detects my userid, it will change the BrickColor to gold, and I have tried this:
1 | if game.Players.LocalPlayer.userid = = ( "1108976841" ) then |
2 | script.parent.BrickColor = BrickColor.new( "Gold" ) |
3 | end |
This does not seem to work. Does anyone have a solution?
if you are using a local script, this is what you should do:
1 | if game.Players.LocalPlayer.UserId = = 1108976841 then -- no brackets and no quotation marks, also, It has to be UserId, not userid (sad). |
2 | script.Parent.BrickColor = BrickColor.new( "Gold" ) |
3 | end |
if you are using a server script, then you should do this:
1 | game.Players.PlayerAdded:Connect( function (player) -- you use the player parameter |
2 | if player.UserId = = 1108976841 then -- the rest is basically the same |
3 | script.Parent.BrickColor = BrickColor.new( "Gold" ) |
4 | end |
5 | end ) |
userid (which is actually supposed to be UserId) requires a number value - not a string:
1 | game.Players.LocalPlayer.UserId = = 1108976841 |
Also, LocalPlayer won't work in a server script (if that's what you're using; if not, be aware that a LocalScript will not display the color for anyone else).
Please excuse me for my dumb mistakes, but I followed all of this advice and none of it worked.