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

Why wont this work (LocalScript)?

Player.CanLoadCharacterAppearance = false

Player.Character.Head.BrickColor = BrickColor.new("Institutional white")
Player.Character.Torso.BrickColor = BrickColor.new("Institutional white")
Player.Character.HumanoidRootPart.BrickColor = BrickColor.new("Institutional white")
Player.Character["Left Arm"].BrickColor = BrickColor.new("Institutional white")
Player.Character["Right Arm"].BrickColor = BrickColor.new("Institutional white")
Player.Character["Left Leg"].BrickColor = BrickColor.new("Institutional white")
Player.Character["Right Leg"].BrickColor = BrickColor.new("Institutional white")
wait()
Player.Character.Head.BrickColor = BrickColor.new("Institutional white")
Player.Character.Torso.BrickColor = BrickColor.new("Institutional white")
Player.Character.HumanoidRootPart.BrickColor = BrickColor.new("Institutional white")
Player.Character["Left Arm"].BrickColor = BrickColor.new("Institutional white")
Player.Character["Right Arm"].BrickColor = BrickColor.new("Institutional white")
Player.Character["Left Leg"].BrickColor = BrickColor.new("Institutional white")
Player.Character["Right Leg"].BrickColor = BrickColor.new("Institutional white")
wait()
Player.Character.Head.face.Texture = "http://www.roblox.com/asset/?id=129003756"


Works perfectly in studio,But when i go play the game it doesnt work. When i press F9 to view the error,It says :

Players.iLegimate.Backpack[C] CharacterLoaded:8: attempt to index field 'Character' (a nil value)
Stack Begin
Script 'Players.iLegimate.Backpack.[C] CharacterLoader', Line 8
Stack end

Help?

2 answers

✓ Accepted answer

I think you need to wait until the character is loaded(or something like that) so maybe adding this on line 2 can help

repeat wait() until--waits until the character is a part of Player()
Player.Character

On this kind of script do NOT make it a local Also if you have game.Players.CanLoadCharacterAppearance=false then ROBLOX can not instance the character. So I would remove Player.CanLoadCharacterAppearance=false or replace Player.CanLoadCharacterAppearance=false with

-- Im guessing that 'Player' = when the player entered?
game:FindService('Players').CanLoadCharacterAppearance=false
wait()
Player:LoadCharacter()

Full coding and fixed should look something like this

-- Im guessing that 'Player' = when the player entered?
function ColorChange(Plr)
pcall(function() -- if you contiune to have a error remove this pcall(function() and the 'end)' at the bottom of the script
local Player=game:FindService('Players')[Plr.Name].Character
game:FindService('Players').CanLoadCharacterAppearance=false
wait()
Player:LoadCharacter()
wait()
Player.Head.BrickColor = BrickColor.new("Institutional white")
Player.Head.face.Texture = "http://www.roblox.com/asset/?id=129003756"
Player.Torso.BrickColor = BrickColor.new("Institutional white")
Player.HumanoidRootPart.BrickColor = BrickColor.new("Institutional white")
Player["Left Arm"].BrickColor = BrickColor.new("Institutional white")
Player["Right Arm"].BrickColor = BrickColor.new("Institutional white")
Player["Left Leg"].BrickColor = BrickColor.new("Institutional white")
Player["Right Leg"].BrickColor = BrickColor.new("Institutional white")
end) -- This end) is for the pcall(function()
end

game.Players.PlayerAdded:connect(function(Plr) -- Your function connecter Do NOT remove.
ColorChange(Plr)
end)

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