AK47xM16
(AK47xM16)
June 2, 2020, 2:04am
#1
For some reason, it fades the transparency 1 by 1 to 0. I want it to be all at once, but I don’t know what I’m doing wrong.
What it looks like: https://gyazo.com/3422da92089a4e5f4b5c8b87c6510afb
for _,v in pairs(Mystand:GetDescendants()) do
if v:IsA(“BasePart”) then
for f = 1,0,-0.5 do
wait()
v.Transparency = f
end
end
end
You should just swap the two and it would work correctly:
local MyStand = ...
for f=1,0,-0.5 do
for i,v in pairs(MyStand:GetDescendants()) do
if v:IsA('BasePart') then
v.Transparency = f
end
end
wait()
end
AK47xM16
(AK47xM16)
June 2, 2020, 2:25am
#3
Hm, I’ve noticed that looping transparency can be laggy sometimes. Is it possible to tween the transparency? I already have the tween arguments set up, but how do I get the whole model as one variable?
local TweenService = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(1) -- Time to tween
local MyStand = ...
for i,v in pairs(MyStand:GetDescendants()) do
if v:IsA('BasePart') then
TweenService:Create(v, TweenInfo, {Transparency = 1})
end
end
2 Likes
@Legoracer didnt play the tween
TweenService:Create(v, TweenInfo, {Transparency = 1}):Play()
And no you cant Tween a model at once but if you do the for loop it actually wouldnt be noticable.
1 Like
Thanks for noticing that, I type most stuff in forum editor so its hard to see everything.
1 Like
MightTea
(MightTea)
June 2, 2020, 3:32am
#7
Wrapping it in a Spawn function should work fine
for _,v in pairs(Mystand:GetDescendants()) do
if v:IsA(“BasePart”) then
spawn(function()
for f = 1,0,-0.5 do
wait()
v.Transparency = f
end
end)
end
end
Using coroutine.create() is better than spawn because like @Kullaske said
spawn(function) has a wait()/a tick in the beginning before running the code. Coroutine doesn’t wait till the next tick to execute.
spawn is delayed.
The title says it all… Basically I want to know in what scenarios I should use:
spawn(function()
-- Script
end)
And what scenarios I should use:
local thing = coroutine.create(function()
-- Script
end)
coroutine.resume(thing)
So… When is it best to use spawn(function() and when it is best to use coroutines?
1 Like
AK47xM16
(AK47xM16)
June 2, 2020, 5:51am
#9
It works fine, but how do I ignore the HumanoidRootPart? I want it to be invisible at all times.
maxen2031
(maxen2031)
June 2, 2020, 5:56am
#10
I would suggest you using a function for the fading part
AK47xM16
(AK47xM16)
June 2, 2020, 6:00am
#11
I already have the transparency tween working fine and smoothly, I just need to know how to ignore the HumanoidRootPart to stay invisible at all times.
maxen2031
(maxen2031)
June 2, 2020, 6:02am
#12
Name the part the same thing and check if their names is that name
AK47xM16
(AK47xM16)
June 2, 2020, 6:14am
#13
Yeah but if I do that, then that’d mean I would have to rename the limbs too and that would break the whole dummy
HumanoidRootPart is normally marked as a PrimaryPart or the RootPart property of the Humanoid.
You can also just iterate and ignore invisible parts since HumanoidRootPart is already transparent.
AK47xM16
(AK47xM16)
June 2, 2020, 6:29am
#16
It doesn’t work, the transparency is still at 0.
AK47xM16
(AK47xM16)
June 2, 2020, 6:29am
#17
I’m not sure how to ignore invisible parts, how would I go about it?
Mixu_78
(Mixu_78)
June 2, 2020, 6:30am
#18
Ignore it when tweening transparency to 0. To ignore invisible parts you just check if part.Transparency == 1
AK47xM16
(AK47xM16)
June 2, 2020, 6:31am
#19
So like this?:
if v:IsA(‘BasePart’) or v:IsA(‘Decal’) and v.Transparency == 1 then
Mixu_78
(Mixu_78)
June 2, 2020, 6:32am
#20
Why the and? Now you are only using invisible parts.
AK47xM16
(AK47xM16)
June 2, 2020, 6:34am
#21
Oh I thought you said to check if part.Transparency == 1, so just put an and there. I’m not sure what else to do.