Necrorave
|
  |
| Joined: 07 Dec 2008 |
| Total Posts: 108 |
|
|
| 02 Jan 2012 11:12 AM |
I am attmepting to make a block slowly vanish until it becomes compeletly transparent and 'CanCollide = false' when you touch it.
Can someone point me in why this is not working? (It does not change Transparency until the very end when it dissappears) If the entire thing is wrong please do not write me a new one. I prefer learning how to do it myself Thank you :)
function Vanish(part)
Player = part.Parent:findFirstChild("Humanoid") Rock = game.Workspace.VanishingRocks:findFirstChild("Rock2") if Player ~= nil then wait(1) Rock.Transparency = 0.2 wait(1) Rock.Transparency = 0.5 wait(1) Rock.Transparency = 0.8 wait(1) Rock.Transparency = 1.0 Rock.CanCollide = false wait(3) Rock.Transparency = 0 Rock.CanCollide = true
end
end
script.Parent.Touched:connect(Vanish) |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2012 11:15 AM |
Well, first, I would suggest an anonymous function to replace your current one.
Second, use a numeric for loop to change the transparency.
Good luck!
(P.S - I almost completely re-wrote it for you, but I saw your note just in time :P) |
|
|
| Report Abuse |
|
|
Necrorave
|
  |
| Joined: 07 Dec 2008 |
| Total Posts: 108 |
|
|
| 02 Jan 2012 11:16 AM |
By anonymous you mean anything but?
And I shall mess around with loops then, see if I can make it dance :D
Thanks alot. |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2012 11:18 AM |
Here's an example of an anonymous function:
game.Workspace.Brick1.Touched:connect(function(hit) end)
Basically, it defines everything in the beginning, and there's no need for a listening line.
If you need more explanation on it, look it up in the wiki! |
|
|
| Report Abuse |
|
|
Necrorave
|
  |
| Joined: 07 Dec 2008 |
| Total Posts: 108 |
|
|
| 02 Jan 2012 11:44 AM |
I put it into a for loop which I believe would work. Although I am a bit unsure how to make the anonymous function even after looking it up.
I didn't want to ask this of anybody but if I were to make my function anonymous how would it look? Would it work?
function Vanish(part)
Player = part.Parent:findFirstChild("Humanoid") Rock = game.Workspace.VanishingRocks:findFirstChild("Rock2")
for x = 0, 5, 1 do wait(1) Rock.Transparency = Rock.Transparency + 0.2 if x = 5 then Rock.CanCollide = false wait(3) Rock.CanCollide = true Rock.Transparency = 0 end
end
end
script.Parent.Touched:connect(Vanish)
|
|
|
| Report Abuse |
|
|
|
| 02 Jan 2012 11:45 AM |
It would look like this, and this is the whole script. No need to add anymore:
~~~~
script.Parent.Touched:connect(function(part)
Player = part.Parent:findFirstChild("Humanoid") Rock = game.Workspace.VanishingRocks:findFirstChild("Rock2")
for x = 0, 5, 1 do wait(1) Rock.Transparency = Rock.Transparency + 0.2
if x = 5 then Rock.CanCollide = false wait(3) Rock.CanCollide = true Rock.Transparency = 0 end
end
end) |
|
|
| Report Abuse |
|
|
Necrorave
|
  |
| Joined: 07 Dec 2008 |
| Total Posts: 108 |
|
|
| 02 Jan 2012 11:48 AM |
I see, thank you very much sir. Sorry for asking someone to do it for me. I really hate to but sometimes I need to be hit with the palm of obviousness.
Thanks alot for your time guys. |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2012 11:49 AM |
Rock = game.Workspace.VanishingRocks:findFirstChild("Rock2") Player = part.Parent:findFirstChild("Humanoid")
Rock.Touched:connect(function(hit) if hit.Parent then if hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Humanoid ~= nil then for i = 0, 1, 0.1 do wait(1) Rock.Transparency = i wait(1) Rock.CanCollide = false wait(3) Rock.CanCollide = true Rock.Transparency = 0 end end end end end) -- Hope this script works! |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2012 11:51 AM |
| Oops, remove the Player variable, it's not in use. :P |
|
|
| Report Abuse |
|
|