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

How to Fix It? It Dosen't Change Black

Asked by 10 years ago
Part = script.Parent

function Touched()
    Part.BrickColor = BrickColor.new("Really black")
end

4 answers

Log in to vote
1
Answered by 10 years ago
Part = script.Parent

function Touched()
    Part.BrickColor = BrickColor.new("Really black")
end
Part.Touched:connect(Touched)

You forgot to put the object that connects to the function therefore making an error.

You seem to be new to functions, i suggest checking out http://wiki.roblox.com/index.php?title=Function for more information ^_^

Ad
Log in to vote
1
Answered by
Marolex 45
10 years ago

The problem is that you have no event firing the function

Part = script.Parent

Part.Touched:connect(function()
    Part.BrickColor = BrickColor.new("Really black")
end)

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

To be very clear: There is nothing special about the name Touched.


Your script defines a function, but nothing here causes that function to happen. The game doesn't know about your function yet, because you haven't told it.

You have to tell it about your function by connecting it to an event, probably the touched event:

Part.Touched:connect( Touched )

Note that the second Touched is just the name of your function -- which could be anything. Here, you're saying, "ROBLOX, please remember the function with the named Touched and whenever this event fires, call that function, Touched".

Without that line, nothing happens since there is nothing to cause the function to be called.

Log in to vote
-5
Answered by 10 years ago

Maybe you should rename Part.

0
No.It dosen't Work Robertandy11 103 — 10y
0
Does black have to be capitalized? Champion121212 22 — 10y
0
Yes.I've tried with and without. Robertandy11 103 — 10y
0
Oh you did forget the bottom part of the function XD Champion121212 22 — 10y

Answer this question