Hey folks, I’m still new to scripting, and I’m trying to make a script that makes an object slowly disappear over time until it reaches transparency 1 at which point it gets parented to nil, but it seems to just delete the object without doing the rest of the script.
I’ve rewritten the script a couple times after doing some research on loops, and I’ve ended up with this:
Object = script.Parent
Transparency = Object.Transparency
while Transparency > 1 do repeat
if Object.Parent.Name == "Katamari" then
while Transparency > 1 do
wait(1)
Transparency = Transparency + 0.1
end
end
until Transparency == 1
end
Object.Parent = nil
It looks as if it should work to me, but clearly I have some gaps in my knowledge since it doesn’t. Does anybody know what I am doing wrong?
You don’t want both… that’s going to create some shenanigans. Try this:
Object = script.Parent
Transparency = Object.Transparency
if Object.Parent.Name == "Katamari" then
while Transparency < 1 do
wait(1)
Transparency = Transparency + 0.1
end
end
Object.Parent = nil
Thankyou, this solved half my issue since the object now disappears in 10 seconds as it should, but It still doesn’t change the transparency for some reason. I think It may have to do with my grammar on line 7, but I’m not sure what should be changed. Any ideas?
Object = script.Parent
Transparency = Object.Transparency
if Object.Parent.Name == "Katamari" then
for i = 0.1, 1, 0.1 do
wait(1)
Object.Transparency = i
end
Object.Parent = nil
end
Ohhh! It works perfectly now, I’ve always had some trouble understanding loops like in line six, I think I’ll do some more research on that in the coming time. Thanks a bunch for your help, have a good week.