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

Something must be wrong w/ skin color gui script?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

I have made me a gui script. You are able to press on a textbutton and it changes the color of you whole body FOR ONLY ME! It seems to be working right but not working for other people. They say something is wrong w/ it.

color1 = 1       
function color()
script.Parent.Parent.Parent.Parent.Parent.Character["Head"].BrickColor = BrickColor.new(color1)
script.Parent.Parent.Parent.Parent.Parent.Character["Torso"].BrickColor = BrickColor.new(color1)
script.Parent.Parent.Parent.Parent.Parent.Character["Left Arm"].BrickColor = BrickColor.new(color1)
script.Parent.Parent.Parent.Parent.Parent.Character["Right Arm"].BrickColor = BrickColor.new(color1)
script.Parent.Parent.Parent.Parent.Parent.Character["Left Leg"].BrickColor = BrickColor.new(color1)
script.Parent.Parent.Parent.Parent.Parent.Character["Right Leg"].BrickColor = BrickColor.new(color1)
end

script.Parent.MouseButton1Down:connect(color)


I always accept answers!

3 answers

Log in to vote
0
Answered by 9 years ago

The problem is that characters have a BodyColors instance in them which overrides the BrickColor property of the parts of the character.

What you want to do is instead of editing the part's BrickColor, you want to edit BodyColors and it's necessary properties so ROBLOX can override the part's BrickColors with your own colors.


Code:

local color1 = 1 --Local variables are obtained quicker than global variables.       
function color()
    script.Parent.Parent.Parent.Parent.Parent.Character["BodyColors"].HeadColor = BrickColor.new(color1)
    script.Parent.Parent.Parent.Parent.Parent.Character["BodyColors"].TorsoColor = BrickColor.new(color1)
    script.Parent.Parent.Parent.Parent.Parent.Character["BodyColors"].LeftArmColor = BrickColor.new(color1)
    script.Parent.Parent.Parent.Parent.Parent.Character["BodyColors"].RightArmColor = BrickColor.new(color1)
    script.Parent.Parent.Parent.Parent.Parent.Character["BodyColors"].LeftLegColor = BrickColor.new(color1)
    script.Parent.Parent.Parent.Parent.Parent.Character["BodyColors"].RightLegColor = BrickColor.new(color1)
end

script.Parent.MouseButton1Down:connect(color)

I would preferably use a LocalScript here and use game.Players.LocalPlayer to get to the character instead of constantly adding parents in as it makes your code look a lot cleaner.

I hope my answer helped you. If it did, be sure to accept it.

0
Does not work. FiredDusk 1466 — 9y
0
Do any errors come up? Spongocardo 1991 — 9y
0
yes FiredDusk 1466 — 9y
0
What is the error? Put it in your question or down here in the comments Spongocardo 1991 — 9y
Ad
Log in to vote
0
Answered by
yoshi8080 445 Moderation Voter
9 years ago

Have you tried a LocalScript?

Log in to vote
0
Answered by 9 years ago

I don't know how to comment but the only thing wrong with Sponge is that Body Colors is a spaced instance so..

local color1 = 1 --Local variables are obtained quicker than global variables.       
function color()
    script.Parent.Parent.Parent.Parent.Parent.Character["Body Colors"].HeadColor = BrickColor.new(color1)
    script.Parent.Parent.Parent.Parent.Parent.Character["Body Colors"].TorsoColor = BrickColor.new(color1)
    script.Parent.Parent.Parent.Parent.Parent.Character["Body Colors"].LeftArmColor = BrickColor.new(color1)
    script.Parent.Parent.Parent.Parent.Parent.Character["Body Colors"].RightArmColor = BrickColor.new(color1)
    script.Parent.Parent.Parent.Parent.Parent.Character["Body Colors"].LeftLegColor = BrickColor.new(color1)
    script.Parent.Parent.Parent.Parent.Parent.Character["Body Colors"].RightLegColor = BrickColor.new(color1)
end

script.Parent.MouseButton1Down:connect(color)

You can also try using a Local Script which I prefer as it makes it cleaner and easier. You can't really connect to the Player without it.

local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character


local color1 = 1 --Local variables are obtained quicker than global variables.       
function color()
    character["Body Colors"].HeadColor = BrickColor.new(color1)
    character["Body Colors"].TorsoColor = BrickColor.new(color1)
    character["Body Colors"].LeftArmColor = BrickColor.new(color1)
    character["Body Colors"].RightArmColor = BrickColor.new(color1)
    character["Body Colors"].LeftLegColor = BrickColor.new(color1)
    character["Body Colors"].RightLegColor = BrickColor.new(color1)
end

script.Parent.MouseButton1Down:connect(color)
0
Tested and both work, happy to help! PancakeChop 35 — 9y

Answer this question