|
| 25 Mar 2009 08:01 PM |
Hmmm...can you help me fix this script? I think it has to do with the if functions...is there a different way of doing that?
function onTouched(hit) if hit.Name == "Rocks" then if hit.Transparency = 0 then hit.Transparecy = 1 elseif hit.Transparency = 1 then hit.Transparecy = 2 elseif hit.Transparency = 2 then hit.Transparecy = 3 elseif hit.Transparency = 3 then hit.Transparecy = 4 elseif hit.Transparency = 4 then hit.Transparecy = 5 elseif hit.Transparency = 5 then hit.Transparecy = 6 elseif hit.Transparency = 6 then hit.Transparecy = 7 elseif hit.Transparency = 7 then hit.Transparecy = 8 elseif hit.Transparency = 8 then hit.Transparecy = 9 elseif hit.Transparency = 9 then hit:remove() end end end
script.Parent.Touched:connect(onTouched)
Beginner scripter. |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2009 08:01 PM |
| Maybe with the use of an and? |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Mar 2009 08:09 PM |
function onTouched(hit) if hit.Name == "Rocks" then if hit.Transparency = 0 then hit.Transparency = .1 elseif hit.Transparency = .1 then hit.Transparency = .2 elseif hit.Transparency = .2 then hit.Transparency = .3 elseif hit.Transparency = .3 then hit.Transparency = .4 elseif hit.Transparency = .4 then hit.Transparency = .5 elseif hit.Transparency = .5 then hit.Transparency = .6 elseif hit.Transparency = .6 then hit.Transparency = .7 elseif hit.Transparency = .7 then hit.Transparency = .8 elseif hit.Transparency = .8 then hit.Transparency = .9 elseif hit.Transparency = .9 then hit:remove() end end end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
|
| 25 Mar 2009 08:12 PM |
| Oh woops! Such a silly mistake! |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2009 08:21 PM |
It still doesn't work though :/
Anyone else have any input here?
|
|
|
| Report Abuse |
|
|
Cull
|
  |
| Joined: 16 Dec 2007 |
| Total Posts: 1252 |
|
|
| 25 Mar 2009 08:32 PM |
| On an "if" line, you need a == instead of an = |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2009 08:36 PM |
| Does the same apply for elseifs? |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2009 08:44 PM |
You cud also do:
function Upgrade(val) if val.Transparency = 9 then val:remove() else val.Transparency = val.Transparency + 1 end end
function onTouched(hit) if hit.Name == "Rocks" then Upgrade(hit) end end
script.Parent.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
Bannana97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 10215 |
|
| |
|
Bannana97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 10215 |
|
| |
|
|
| 25 Mar 2009 11:06 PM |
| Would that work with the 2 ifs like that? Ill have to experiment i a minute. |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2009 11:12 PM |
| Alright sorry for all these posts guys but I got it working a bit. It goes to transparency 0.1 then stays there. Any ideas? Ill try to fix this too. |
|
|
| Report Abuse |
|
|
Bannana97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 10215 |
|
| |
|
Davidii
|
  |
| Joined: 17 Jul 2008 |
| Total Posts: 1282 |
|
|
| 26 Mar 2009 09:30 AM |
Here is a simple solution.
Going from 0 Transparency to 1 Transparency (then remove)
function onTouched(hit) hit.Transparency = hit.Transparency + 0.1 if hit.Transparency < 0.1 then hit:remove() end end
script.Parent.Touched:connect(onTouched)
Going from 1 Transparency to 0 Transparency (then remove)
function onTouched(hit) hit.Transparency = hit.Transparency - 0.1 if hit.Transparency > 0.9 then hit:remove() end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
kingddda
|
  |
| Joined: 11 Mar 2009 |
| Total Posts: 63 |
|
|
| 26 Mar 2009 10:25 AM |
| I need help with where to put () and what to put in the exp: script.Parent.Anchored = true |
|
|
| Report Abuse |
|
|