|
can someone help me finish this script please. just a little info on what im trying to do, i want a button that when i press it, the brick changes colour from eg red to green, then back
function onClicked()
if workspace.(BRICKNAME).Value.Value == true then
workspace.BrickNAME.Color = Color3.new(#,#,#) --experiment with different numbers here
end
if workspace.BRICKNAME.Value.Value == false then
workspace.BRICKNAME.Color = Color3.new(#,#,#)
end end
then a connection line i dont know
please help me! |
|
lasassinJoin Date: 2009-02-27 Post Count: 831 |
My example for a button containing a ClickDetector:
------------------------------------------------------------------
brick = game.Workspace.BRICKNAME
function onClick()
if brick.Color = Color3(255,0,0) then --Is the button red?
brick.Color = Color3.new(0,255,0) --Make it green
end
if brick.Color = Color3(0,255,0) then --Is the button green?
brick.Color = Color3.new(255,0,0) --Make it red
end end
script.Parent.ClickDetector.MouseClick:connect(onClick)
------------------------------------------------------------------
That is how I would do it, I'm not sure if it works, I haven't tried something like this before. The brick color would have to be pure red for this to work though, I'm not sure how to do it using BrickColor. |
|
|
ahh thanks ill try it and tell you what happens |
|
|
unfortunately, it didnt work, i think it needed of some kind of connector |
|
|
brick.BrickColor = BrickColor.new("Bright red") eccact name from the brick colors tab there. like:
brick.BrickColor = BrickColor.new("Lime green")
wait(0.1)
brick.BrickColor = BrickColor.new("Really red")
|
|
|
lassasin's wouldn't work. He said: "if brick.Color = Color.new(255, 0, 0)"
something like that... But we know, for IF statements you always need two '='s.
And I'm not sure, but I dont think you can do "brick.Color". At least, I have never tried. |
|
|
lets pretend the brick's name is "Party".
function onClicked()
if Workspace.Party.Value.Value == true then
Workspace.Party.BrickColor = BrickColor.new("Lime green")
elseif Workspace.Party.Value.Value == false then
workspace.Party.BrickColor = BrickColor.new("Bright red")
end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
try that. Of course you might need to tweek it, because I dont know what you really want for everything, or how your using this script. |
|
|
it didnt worked, what im trying to do is that i want a system where when i press a button, the bricks turn to some colours eg green to red, not the button itself, but another brick |
|
|
just like a bulb, you press a swithc, the bulb turns on, however the bulb here is a brick but it changes colour |
|
|
Well you didn't necessarily tell me that now did you. Plus, I said tweak it, I'm not making a script for you, I'm helping you. |
|
|
ok i made a script and tested it, but it still didnt worked
local switch = script.Parent
local light
function onClicked()
if Workspace.light.Value.Value == true then
Workspace.light.BrickColor = BrickColor.new("Lime green")
else if Workspace.light.Value.Value == false then
end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
local switch = script.Parent
local light
function onClicked()
if Workspace.light.Value.Value == true then
Workspace.light.BrickColor = BrickColor.new("Really red")
else if Workspace.light.Value.Value == false then
end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
|
Lasassin's wouldn't work anyway, it'd change to green but within a frame change back to red, use elseif instead. |
|
lasassinJoin Date: 2009-02-27 Post Count: 831 |
Yeah I realised mine wouldn't work, since I forgot to use == instead of =, and I guess my mind was stuck on making smoke and stuff with the .Color
That should be .BrickColor shouldn't it... |
|
|
brick.Color = Color3.new(0,255,0) --Make it green
elseif brick.Color == Color3(0,255,0) then --Is the button green?
:/ |
|
|
apparently, none of them works, wow i couldnt believe that making a simple switch that makes a brick change colour can be difficult |
|
pauljklJoin Date: 2008-10-23 Post Count: 9364 |
This work?
brick = game.Workspace.BRICKNAME
function onClick()
if brick.BrickColor == BrickColor.new(21) then
brick.BrickColor = BrickColor.new(28) --Make it green
end
if brick.BrickColor == BrickColor.new(21) then
brick.BrickColor = BrickColor.new(28)
end end
script.Parent.ClickDetector.MouseClick:connect(onClick)
|
|
|
lasassinJoin Date: 2009-02-27 Post Count: 831 |
Yeah I have to agree with you newjersey00, this is surprisingly hard for such a simple task. But that's what coding is pretty much about right? :P |
|
|
yes its quite right, although i think some coding are missing, which inhibits us to finish this task |
|
07lchrisJoin Date: 2010-02-28 Post Count: 1603 |
script.Parent.ClickDetector.MouseClick:connect(function(onClicked)
if script.Parent.BrickColor == BrickColor.new("Lime green")
then
script.Parent.BrickColor = BrickColor.new("Really red")
elseif script.Parent.BrickColor == BrickColor.new("Really red")
then
script.Parent.BrickColor = BrickColor.new("Lime green")
end
end) |
|
|
yes! it worked, now i need to make a switch for it |
|
|
lasassinJoin Date: 2009-02-27 Post Count: 831 |
@sircfenner
Yeah I forgot that :D
I made my script at like 11 pm, so my brain wasnt really working too well :P |
|
|
ok i made a switch for them and a script
script.Parent.ClickDetector.MouseClick:connect(myfunction)
script.Parent.ClickDetector.MouseClick:connect(function(onClicked)
script.Parent.Lighty123
if script.Parent.Lighty123 == BrickColor.new("Lime green")
then
script.Parent.Lighty123 = BrickColor.new("Really red")
elseif script.Parent.Lighty123 == BrickColor.new("Really red")
then
script.Parent.Lighty123 = BrickColor.new("Lime green")
end
end)
however, no suporise to me, it didnt worked 0.o, can anyone help me on this. Btw the "Lighty123" bit is the brick that changes colour |
|