The goal of this script is to continuously run in a loop, always hitting the "else" statement until it eventually turns "Visible" and then it would end the loop.
Clearly that's not whats happening! Currently when running it does print "Invisible" once then stops, meaning its not looping. I believe my error lies in the "until found" line, but I'm unsure of how to run this the correct way.
For backstory this is a tycoon and i need this to activate once an object is purchased and moved into the referenced location with referenced name.
local found = script.Parent.Parent.Parent.Parent.PurchasedObjects:FindFirstChild("FirstFloorStairs") if found then print("Visible") script.Parent.Transparency = .5 else print("Invisible") script.Parent.Transparency = 1 repeat until found end
Any pointers or help is much appreciated, I'm very new to the scene :).
EDIT
local list = script.Parent.Parent.Parent.Parent.PurchasedObjects:GetChildren() -- get the list of items in a loop for _, v in pairs(list) do if v.Name == "FirstFloorStairs" then script.Parent.Transparency = .5 -- visible!! print("Visible") end end
local ts = game:GetService("TweenService") --tween service local list = script.Parent.Parent.Parent.Parent.PurchasedObjects:GetChildren() --just a list local tinfo = TweenInfo.new( 0.7,--time it takes to tween Enum.EasingStyle.Sine,--the easing style(mainly for looks) Enum.EasingDirection.Out,--again for aestetics 0,--times it repeats false,--whether it reverses 0-- delay between repeats )--tween info local properties = {Transparency = .5} for _, v in pairs(list) do if v.Name == "FirstFloorStairs" then -- if the item is a part script.Parent.Transparency = 1 -- make the blocks invsible local tween = ts:Create(script.Parent,tinfo,properties)--creates a tween tween:Play() end end -- create a loop
So basically you want a fading block, and when the fading ends it should stop the loop? EASY!!!
So I am assuming you wanna make everything in a model transparent then change the transparency to + .01
change list to your model, don't remove GetChildren()
local list = script.Parent:GetChildren() -- get the list of items in a loop local counter -- just set up a little counter for _, v in pairs(list) do if v.ClassName = "Part" then -- if the item is a part then... v.Transparency = 1 -- invisible!! -- now for the visibility code!! counter = 100 repeat wait(.001) counter = counter - 1 v.Transparency = v.Transparency - 0.01 until counter < 1 end end -- create a loop
This code above does the fading effects, I havent tested it in studio but, this should probably work!
If you want another part to exist and then make another part appear??? then do this: EVEN EASIER XDDD
local part_To_Exist = workspace:WaitForChild("Item") -- use wait for child to wait until that item exists!! local part_to_change = script.Parent -- change the transparency of the part that is suppose to already exist repeat wait() until part_To_Exist part_to_change.Transparency = 0
the transparency of the part changes when the exist part is created!!
Tell me if you are using a model!
Yes, I think greatneil80's solution works, but I think it is a bit more practical to tween the transparency of the parts
local ts = game:GetService("TweenService") --tween service local list = script.Parent:GetChildren() --just a list local tinfo = TweenInfo.new( 0.7,--time it takes to tween Enum.EasingStyle.Sine,--the easing style(mainly for looks) Enum.EasingDirection.Out,--again for aestetics 0,--times it repeats false,--whether it reverses 0-- delay between repeats )--tween info local properties = {Transparency = 1} for _, v in pairs(list) do if v.ClassName = "Part" then -- if the item is a part v.Transparency = 0 -- make the blocks invsible local tween = ts:Create(v,tinfo,properties)--creates a tween tween:Play() end end -- create a loop
That is the general basics on how to use tweens, you can play around a bit with the easing styles, the easing directions, and other aspects of the tween info and part properties