I was making the person who clicked it, turn into a certain thing but the body colors and such won't change? local script
local player = game.Players.LocalPlayer.Character local shirt = player:FindFirstChild("Shirt") local pants = player:FindFirstChild("Pants") local face = player.Head:FindFirstChild("face") local tshirt = player:FindFirstChild("Shirt Graphic") local mesh = player:FindFirstChild("CharacterMesh") local hats = player:FindFirstChild("Hat") local body = player:FindFirstChild("Body Colors") function onClick() body.HeadColor = BrickColor.new("Bright yellow") body.TorsoColor = BrickColor.new("Bright blue") body.LeftArmColor = BrickColor.new("Bright yellow") body.RightArmColor = BrickColor.new("Bright yellow") body.LeftLegColor = BrickColor.new("Bright green") body.RightLegColor = BrickColor.new("Bright green") shirt:remove() pants:remove() tshirt:remove() mesh:remove() hats:remove() face.Texture = "http://www.roblox.com/asset/?id=155216144" end script.Parent.MouseButton1Down:connect(onClick)
Error: Players.Player.PlayerGui.ShopGUI.GearFrame.Frame.ImageButton.LocalScript:10: attempt to index upvalue 'body' (a nil value)
I'm not entirely sure why your script isn't working, but replace the script you've got with a normal script (not local) because otherwise only the player will see the character change. Use this code for the script:
char = script.Parent.Parent.Parent.Parent.Parent.Parent.Character script.Parent.MouseButton1Down:connect(function() for i,v in pairs(char:GetChildren()) do if v:IsA("BodyColors") then v.HeadColor = BrickColor.new("Bright yellow") v.TorsoColor = BrickColor.new("Bright blue") v.LeftArmColor = BrickColor.new("Bright yellow") v.RightArmColor = BrickColor.new("Bright yellow") v.LeftLegColor = BrickColor.new("Bright green") v.RightLegColor = BrickColor.new("Bright green") elseif v:IsA("Hat") or v:IsA("CharacterMesh") or v:IsA("ShirtGraphic") or v:IsA("Shirt") or v:IsA("Pants") then v:remove() elseif v.Name == "Torso" and v:FindFirstChild("roblox") ~= nil then v.roblox:remove() elseif v.Name == "Head" then v.face.Texture = "http://www.roblox.com/asset?id=155216144" end end end)
When setting a Color to properties, such as a Part's Color, you must use BrickColor.new()
, so it can set it's color.
body.HeadColor = BrickColor.new("Bright yellow") body.TorsoColor = BrickColor.new("Bright blue") body.LeftArmColor = BrickColor.new("Bright yellow") body.RightArmColor = BrickColor.new("Bright yellow") body.LeftLegColor = BrickColor.new("Bright green") body.RightLegColor = BrickColor.new("Bright green")
By the way, there's a way more efficient way to remove Shirts, Pants, and even changing the colors by using a For loop.