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

What is wrong with this basic script?

wait(1)
local Player = game.Players.LocalPlayer
ra = Player.Character:FindFirstChild("Right Arm")

if ra.BrickColor then
	
	script.Parent.Handle.BrickColor.Color = ra.BrickColor.Color
	 

end

I want to find the color of the characters right arm and make it the color of the Handle This is in a LocalScript

2 comments

0

Does it error?

0

Have you tried removing '.BrickColor' on line 05, and replaced the 'FindFirstChild' method with the 'WaitForChild' method..? :) *The 'WaitForChild' method yields the code until a Child (within the Parent) with the exact name as the Argument comes within existence, then will return the Instance.

3 answers

This might work:

wait(1)

Player = game.Players.LocalPlayer

local ra = Player.Character:FindFirstChild("Right Arm")

if ra.BrickColor then

  script.Parent.Handle.BrickColor = BrickColor.new(ra.BrickColor)

end

Sorry if I'm wrong.

If this is in a part, I don't think you can use LocalPlayer. So try this:

player =script.Parent.Parent
wait(1)
Player:WaitForChild("Right Arm")
script.Parent.Handle.BrickColor.Color = ra.BrickColor.Color



This should work...

local Player = game.Players.LocalPlayer
repeat wait() until Player.Character.Humanoid ~= nil -- Checks to make sure the Players Character is Loaded
ra = Player.Character:FindFirstChild("Right Arm")

if ra then -- Checks to make sure ra Exists
    script.Parent.Handle.BrickColor = BrickColor.new( ra.BrickColor)
end

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