|
| 12 Jan 2013 04:29 PM |
Hi,
I have a script which makes a model fade out and then fade in when i press the button again. The fade out is fine but when i fade it back instead of the transparency going from 1 to 0 it goes 1 to 3.502e-009 however each function has for i=1,10 so that should happen. For some reason for i=1,10 doesn't work or at least i don't think it does so i put in a repeat to change the transparency as well just in case and the repeat stops working when a=10 but the transparency just goes over 0 to 3.502e-009
I can paste the script if needs be. Thanks! |
|
|
| Report Abuse |
|
|
itunes89
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 1957 |
|
|
| 12 Jan 2013 04:36 PM |
| Yea, can you post the script? |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2013 04:36 PM |
local main = script.Parent.Parent.Parent.Parent.Parent.Parent local full = main.Parent local entry = full.Entry local fuse = main.Fused local Cloaked = main.Cloaked
function Cloakoff() if (fuse.Value == true) then return end if (Cloaked.Value == true) then local cloak = Cloaked.Value main.Parts.ConsolePlat.Console.CenterThing.Uncloak:Play() entry.Base.Uncloak:Play() for i=1, 10 do local amount = ({[true] = -0.1/10,[false] = 0.1/10})[cloak] recursiveTransparency(entry,amount) wait(0.02) end Cloaked.Value = false end end script.Parent.ClickDetector.MouseClick:connect(Cloakoff)
function Cloakon() if (fuse.Value == true) then return end if (Cloaked.Value == false) then local cloak = Cloaked.Value main.Parts.ConsolePlat.Console.CenterThing.Cloak:Play() entry.Base.Cloak:Play() for i=1, 10 do local amount = ({[true] = -0.1/10,[false] = 0.1/10})[cloak] recursiveTransparency(entry,amount) wait(0.02) end Cloaked.Value = true end end script.Parent.ClickDetector.MouseClick:connect(Cloakon)
function recursiveTransparency(parent,trans) if (parent == nil) then return end trans = trans or 0
for k,v in pairs(parent:GetChildren()) do if (v:IsA("BasePart")) then a=0 repeat v.Transparency = v.Transparency+trans a=a+1 until (a==10) end if (#v:GetChildren() > 0) then recursiveTransparency(model,trans) end end end |
|
|
| Report Abuse |
|
|
itunes89
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 1957 |
|
|
| 12 Jan 2013 04:42 PM |
| It's hard to find a problem in this because it's so long. Print out the value as it changes and see where it goes wrong. That's really all I can say. |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2013 04:44 PM |
| It's not rather it doesn't work. It just works to much. Like i said instead of going 1 to 0 it goes 1 to 3.52 + e or whatever... I just cut out the relevant parts... |
|
|
| Report Abuse |
|
|
itunes89
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 1957 |
|
|
| 12 Jan 2013 04:45 PM |
| Just do what I said. You'll find the problem. |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2013 04:45 PM |
for i=1, 10 do local amount = ({[true] = -0.1/10,[false] = 0.1/10})[cloak] recursiveTransparency(entry,amount)
for i=1, 10 do local amount = ({[true] = -0.1/10,[false] = 0.1/10})[cloak] recursiveTransparency(entry,amount)
for k,v in pairs(parent:GetChildren()) do if (v:IsA("BasePart")) then a=0 repeat v.Transparency = v.Transparency+trans a=a+1 until (a==10) end |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2013 04:50 PM |
It doesn't make an error! It just doesn't do what it should do. Fadeout the transparency goes from 0 to 1 which is good. That's what it should do. But when fading back in it goes from 1 to 3.52+e which it shouldn't and i can't find anything in the script that makes it go from 1 to 3.52+e when it should go from 1 to 0 |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
Saltless
|
  |
| Joined: 24 Dec 2012 |
| Total Posts: 107 |
|
|
| 14 Jan 2013 02:58 PM |
Transparency isn't 1-10, it's 0-1
Change "for i = 1, 10 do" to "for i = 0, 1, .1 do"
-- A fry without salt is like a world without hate. |
|
|
| Report Abuse |
|
|