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

how do i make it when someone stands on a block it turns another block's clour different?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

thanks but I'm terriable at scripting so I don't know how to join it up plz help.

I'm trying to make a script that when someone stands on it it makes a different block turn green then back to red plz help its here.

while true do ontouch.Parent = wait(2) 'Part1' colour:Limegreen wait (2) then 'Part1' = colour:Really red end end

0
Edit your post to use the Lua code formatting block. Select your code and press the Lua button. A line of ~~~ should appear before and after the code. BlueTaslem 18071 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Well.

I'm not sure if that's even Lua, but let's get on with it:

There's a property of parts called Touched. You want to change the color of the part, so first you'll need to hook up a function to fire when the part is touched. How would we do that? Like this

--A script, inside of a part, inside of whatever.
script.Parent.Touched:connect(function()

end)

Good, so now we have that. Now, to changed color, there is another property that changes the color of something; it's called BrickColor. To change this property with a script, we would do this:

game.Workspace.Part.BrickColor = BrickColor.new("Bright red")

So, what can we do with the two things that we just learned? We can hook up the event to change the brick color based on what the brickcolor already is, like so:

script.Parent.Touched:connect(function()
    if script.Parent.BrickColor == "Black" then
        script.Parent.BrickColor = BrickColor.new("White")
    end
    if script.Parent.BrickColor == "White" then
        script.Parent.BrickColor = BrickColor.new("Black")
    end
end)

On a final note, you should always check the wiki for a tutorial. I know there's one on the wiki having to do something with this.

Hope this helps.

Ad

Answer this question