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

How do you change the body color of a player, with a local script?

Asked by 6 years ago
Edited 6 years ago

Hi, I tried making a script that changes a players color when they click F. But for some reason this error keeps on showing up:

18:53:10.311 - ContextActionService: Unexpected error while invoking callback: Players.turbomegapower12345.PlayerGui.ZeusPowers:42: attempt to index global 'RightArmColor' (a nil value)

Here is my script:

01local player = game.Players.LocalPlayer
02local character = player.CharacterAdded:Wait()
03local head = character:WaitForChild("Head")
04 
05local Humanoid = character:WaitForChild("Humanoid")
06local torso = character.UpperTorso
07local mouse = player:GetMouse()
08 
09local bodycolors = character:WaitForChild("Body Colors")
10 
11 
12local Workspace = game.Workspace
13 
14 
15local target
View all 98 lines...
0
Does any1 know a solution? turbomegapower12345 48 — 6y

2 answers

Log in to vote
0
Answered by
aazkao 787 Moderation Voter
6 years ago
Edited 6 years ago

Your syntax is wrong, use this

1bodycolors.RightArmColor = BrickColor.new("Dark blue")
Ad
Log in to vote
0
Answered by 6 years ago

you can use a for i,v in pairs() loop which can change the players limbs and bodypart colours like this:

1local bodyparts = game.Players.LocalPlayer.Character:GetChildren()
2 
3for _,body in pairs(bodyparts) do
4    if body:IsA("Part") then -- checks if its a part
5        body.BrickColor = BrickColor.new("Dark blue") -- changes colour
6    end
7end

but if u want it to change a certain bodypart, like u only did the rightarm you can do this:

1local bodyparts = game.Players.LocalPlayer.Character:GetChildren()
2 
3for _,body in pairs(bodyparts) do
4    if body.Name = "RightArm" then -- checks if the name is "RightArm"
5        body.BrickColor = BrickColor.new("Dark blue") -- changes colour
6    end
7end
0
doesnt work turbomegapower12345 48 — 6y

Answer this question