|
| 27 Dec 2013 05:25 AM |
I made a script which is supposed to change the transparency of the brick when the brick is clicked this is what I have so far but it won't work, please edit it if you know what the right script would be!
function OnClick(mouse) if script.Parent.Transparency = 0 then (OnClick) script.Parent.Transparency = 1 else if script.Parent.Transparency = 1 then (OnClick) script.Parent.Transparency = 0 end end script.Parent.ClickDetector.MouseClick:connect(OnClick) |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 05:30 AM |
function OnClick(mouse) if script.Parent.Transparency == 0 then -- Should be two equal signs since it's a statement script.Parent.Transparency = 1 else if script.Parent.Transparency == 1 then --Same here script.Parent.Transparency = 0 end end
script.Parent.ClickDetector.MouseClick:connect(OnClick) |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 05:43 AM |
No change but if I do this it makes it invisible but then I want it to be able to put it back by clicking again:
function OnClicked(playerWhoClicked) script.Parent.Transparency = 1 end
script.Parent.ClickDetector.MouseClick:connect(OnClicked) |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 05:46 AM |
clicked = false
script.Parent.ClickDetector.MouseClick:connect(function() local part = script.Parent if part.Transparency == 0 and clicked == false then part.Transparency = 1 clicked = true elseif part.Transparency == 1 and clicked == true then part.Transparency = 0 clicked = false end
|
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 05:47 AM |
clicked = false
script.Parent.ClickDetector.MouseClick:connect(function() local part = script.Parent if part.Transparency == 0 and clicked == false then part.Transparency = 1 clicked = true elseif part.Transparency == 1 and clicked == true then part.Transparency = 0 clicked = false end end)
Forgot to add another end woops. |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Dec 2013 09:04 AM |
function OnClick(mouse) script.Parent.Transparency = 0 elseif script.Parent.Transparency == 0 then script.Parent.Transparency = 1 end-- May or may not need this end... Not sure with elseif statements.. script.Parent.ClickDetector.MouseClick:connect(OnClick) |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 09:05 AM |
Nvm, fixed.
function OnClick(mouse) script.Parent.Transparency = 0 elseif script.Parent.Transparency == 0 then script.Parent.Transparency = 1 end end script.Parent.ClickDetector.MouseClick:connect(OnClick) |
|
|
| Report Abuse |
|
|
| |
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 27 Dec 2013 09:39 AM |
function OnClick(mouse) if script.Parent.Transparency == 1 then script.Parent.Transparency = 0 elseif script.Parent.Transparency == 0 then script.Parent.Transparency = 1 end end
script.Parent.ClickDetector.MouseClick:connect(OnClick) |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 09:49 AM |
Got it anyways:
function OnClicked(playerWhoClicked) if script.Parent.Transparency == 0 then script.Parent.Transparency = 1 elseif script.Parent.Transparency == 1 then script.Parent.Transparency = 0 end end
script.Parent.ClickDetector.MouseClick:connect(OnClicked) |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 27 Dec 2013 09:49 AM |
| Ahh.. that's the same as what I gave you, except you renamed some variables :P |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 09:56 AM |
| You posted it the same time I made the script a model so I didn't copy yours... |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
| |
|
| |
|