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

How do I Change the Color of a ball into the color of a player's torso?

Asked by 9 years ago

I want make a ball that when a player touches it, It will change the color of the ball into the same color of the player's torso. Lets say if my torso color is green When touch it, it turns green.

2 answers

Log in to vote
0
Answered by 9 years ago
--script inside of the ball

local ball = script.Parent
--a reference to the ball. We can manipulate the ball's properties using this variable.

ball.Touched:connect(function(hit)
--We are listening for the touched event on the ball.
--When the ball is touched, it runs the given code, and sets the variable "hit" to whatever touched the ball.

    if hit.Parent:FindFirstChild("Humanoid") then
    --check to see if parent of whatever hit the ball has a humanoid
    --if the parent contains a humannoid, then it will run the given code. 

    ball.BrickColor = hit.Parent:FindFirstChild("Torso").BrickColor
    --change the ball's color to the color of the player's torso

    end
end)
0
Thanks but what if I want to use it in a sever script? Zeckrahm 0 — 9y
0
change "script.Parent" on line 3 to a reference to the ball in the workspace. aquathorn321 858 — 9y
0
how do you answer in code like that? QsDoes 0 — 5y
Ad
Log in to vote
-1
Answered by 9 years ago

You can do this two ways. 1, part.BrickColor = BrickColor.new(player.Character.Torso.BrickColor) or part.BrickColor = BrickColor.new(player.Character["Body Colors"].TorsoColor). Keep in mind that this isn't a request site next time.

0
The script dose not know what player is. What do I do? Zeckrahm 0 — 9y

Answer this question