Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I have multiple objects fade from one function?

Asked by
Vrakos 109
10 years ago

Lets say that I have a function that places a gui and makes it fade after 5 seconds, but I call the function three times and there's three frames.

Whenever I try this, two don't fade but the last one that was created does.

I'm really confused with this.

Here's the script (Sorry, I forgot it):

GUIs                = game.ServerStorage.GUIs

function ErrorToPlayer(Player,Err)
    coroutine.resume(coroutine.create(function()
        for Index,Gui in pairs(Player.PlayerGui.PlayerClick:GetChildren()) do
            if Gui.Name == "Error" then
                Gui:TweenPosition(Gui.Position+UDim2.new(0,0,0,20),"InOut","Quad",.25,true)
            end
        end
        Error = GUIs["Error"]:Clone() 
        Error.Text = Err 
        Error.Parent = Player.PlayerGui.PlayerClick
        game.Debris:AddItem(Error,6)
        wait(5)
        for i = 0,1,.1 do
            Error.BackgroundTransparency = 1-.5*i
            Error.TextTransparency = i
            Error.TextStrokeTransparency = 1-.5*i
            wait()
        end
    end))
end

ErrorToPlayer(game.Players.Player1,"HEY") 
ErrorToPlayer(game.Players.Player1,"HEY") 
ErrorToPlayer(game.Players.Player1,"HEY")
0
This really is a question about what you are doing wrong in your implementation -- can you provide what you've tried so that we can see what needs fixing? BlueTaslem 18071 — 10y
0
Edited post. Vrakos 109 — 10y

1 answer

Log in to vote
0
Answered by
HexC3D 830 Moderation Voter
10 years ago
gui = {ScreenGui.Frame,ScreenGui2.Frame,ScreenGui3.Frame}
for i,v in pairs (game.Players:GetPlayers() ) do
for i = 1,#gui do
v:WaitForDataReady("ScreenGui").gui[i].Transparency  = 0.2
wait()
v:WaitForDataReady("ScreenGui").gui[i].Transparency  = .5
wait()
v:WaitForDataReady("ScreenGui").gui[i].Transparency  = 1

end
end

This script is very badly written but works best hopes HexC3D , took me like 1 min :)

Ad

Answer this question