My code will turn you into a noob, but my code doesn't do so when it runs.
script.Parent.Touched:connect(function(player) player.Parent.Torso.BrickColor = BrickColor.new("Really Blue") player.Parent.RightLeg.BrickColor = BrickColor.new("Forest Green") player.Parent.LeftLeg.BrickColor = BrickColor.new("Forest Green") player.Parent.RightArm.BrickColor = BrickColor.new("New Yeller") player.Parent.LeftArm.BrickColor = BrickColor.new("New Yeller") player.Parent.Head.BrickColor = BrickColor.new("New Yeller") player.Parent.Shirt.Destroy() player.Parent.Pants.Destroy() end)
Output result: "18:29:22.524 - RightLeg is not a valid member of Model 18:29:22.528 - Script 'Workspace.Noobifier.Head.Script', Line 3 18:29:22.531 - Stack End"
So how do I make the parameter be for the player who touched the part?
In order to fix this, you have to use FindFirstChild
.
Here's the following script,
script.Parent.Touched:connect(function(player) player.Parent.Torso.BrickColor = BrickColor.new("Really Blue") player.Parent:FindFirstChild("Right Leg").BrickColor = BrickColor.new("Forest Green") player.Parent:FindFirstChild("Left Leg").BrickColor = BrickColor.new("Forest Green") player.Parent:FindFirstChild("Right Arm").BrickColor = BrickColor.new("New Yeller") player.Parent:FindFirstChild("Left Arm").BrickColor = BrickColor.new("New Yeller") player.Parent.Head.BrickColor = BrickColor.new("New Yeller") player.Parent.Shirt.Destroy() player.Parent.Pants.Destroy() end)
I would also suggest using an if statement to make sure that what touched the brick is a Humanoid.
script.Parent.Touched:connect(function(player) if not player.Parent:FindFirstChild("Humanoid") then return end player.Parent.Torso.BrickColor = BrickColor.new("Really Blue") player.Parent:FindFirstChild("Right Leg").BrickColor = BrickColor.new("Forest Green") player.Parent:FindFirstChild("Left Leg").BrickColor = BrickColor.new("Forest Green") player.Parent:FindFirstChild("Right Arm").BrickColor = BrickColor.new("New Yeller") player.Parent:FindFirstChild("Left Arm").BrickColor = BrickColor.new("New Yeller") player.Parent.Head.BrickColor = BrickColor.new("New Yeller") player.Parent.Shirt.Destroy() player.Parent.Pants.Destroy() end)
I hope I helped!
Good Luck!