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
01wait(1)
02local Player = game.Players.LocalPlayer
03ra = Player.Character:FindFirstChild("Right Arm")
04 
05if ra.BrickColor then
06 
07    script.Parent.Handle.BrickColor.Color = ra.BrickColor.Color
08 
09 
10end

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:

01wait(1)
02 
03Player = game.Players.LocalPlayer
04 
05local ra = Player.Character:FindFirstChild("Right Arm")
06 
07if ra.BrickColor then
08 
09  script.Parent.Handle.BrickColor = BrickColor.new(ra.BrickColor)
10 
11end

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:

1player =script.Parent.Parent
2wait(1)
3Player:WaitForChild("Right Arm")
4script.Parent.Handle.BrickColor.Color = ra.BrickColor.Color
Log in to vote
-1
Answered by
Dr_Doge 100
9 years ago

This should work...

1local Player = game.Players.LocalPlayer
2repeat wait() until Player.Character.Humanoid ~= nil -- Checks to make sure the Players Character is Loaded
3ra = Player.Character:FindFirstChild("Right Arm")
4 
5if ra then -- Checks to make sure ra Exists
6    script.Parent.Handle.BrickColor = BrickColor.new( ra.BrickColor)
7end

Answer this question