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

What is wrong with this basic script?

Asked by 9 years ago
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

0
Does it error? ClassicTheBlue 65 — 9y
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. TheeDeathCaster 2368 — 9y

3 answers

Log in to vote
0
Answered by
nanaluk01 247 Moderation Voter
9 years ago

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.

Ad
Log in to vote
-1
Answered by
ItsMeKlc 235 Moderation Voter
9 years ago

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



Log in to vote
-1
Answered by
Dr_Doge 100
9 years ago

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

Answer this question