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

Why doesn't this work?

Asked by 10 years ago
math.randomseed(tick())

local skinT = {"125", "1030", "18"}

local player = game.Players.LocalPlayer
while not player.Character do
    wait()
end
local character = player.Character

local bColors = character:FindFirstChild("Body Colors")

if bColors ~= nil then

local newskin = skinT[math.random(1,3)]     

bColors.HeadColor = BrickColor.new(newskin)
bColors.LeftArmColor = BrickColor.new(newskin)
bColors.RightArmColor = BrickColor.new(newskin)
bColors.TorsoColor = BrickColor.new(newskin)
bColors.LeftLegColor = BrickColor.new(newskin)
bColors.RightLegColor = BrickColor.new(newskin)
end 


Output isn't giving me any errors, so I'm very confused.

1 answer

Log in to vote
1
Answered by
2eggnog 981 Moderation Voter
10 years ago

This works. The body colors were being added to the character slightly after the character spawned, so I changed FindFirstChild to WaitForChild.

math.randomseed(tick())

local skinT = {"125", "1030", "18"}

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

local bColors = character:WaitForChild("Body Colors")

local newskin = skinT[math.random(1,3)]     

bColors.HeadColor = BrickColor.new(newskin)
bColors.LeftArmColor = BrickColor.new(newskin)
bColors.RightArmColor = BrickColor.new(newskin)
bColors.TorsoColor = BrickColor.new(newskin)
bColors.LeftLegColor = BrickColor.new(newskin)
bColors.RightLegColor = BrickColor.new(newskin)
Ad

Answer this question