Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is the best way to create a fade GUI while the player is seated?

I am having trouble figuring out how I am able to create a fade GUI when a player is sitting in a seat.

My current fade script:

local part = game.Workspace.Fade 

game.Players.PlayerAdded:Connect(function(plr)
    local bgui = Instance.new("ScreenGui")
    local bframe = Instance.new("Frame")

    bgui.Parent = plr:WaitForChild("PlayerGui")
    bgui.Name = "BlackoutGUI"
    bframe.Parent = bgui
    bframe.BackgroundTransparency = 1
    bframe.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
    bframe.Size = UDim2.new(10000000, 10000000, 10000000, 10000000)
end)

part.Touched:Connect(function(hit)
    local activated = false
    local player = hit.Parent.Name
    if activated == false then
        activated = true 
        for count = 1, 5 do
            game.Players:FindFirstChild(player):WaitForChild("PlayerGui").BlackoutGUI.Frame.BackgroundTransparency = game.Players:FindFirstChild(player):WaitForChild("PlayerGui").BlackoutGUI.Frame.BackgroundTransparency - 0.050
            wait(0.1)
        end
        activated = false
    end
end)

1 answer

✓ Accepted answer
local FadeFrame = function(Entity, Speed)
	repeat
		Entity.Transparency = Entity.Transparency + .01 ; wait(Speed)
	until Entity.Transparency == 1
end

spawn(FadeFrame(script.Parent, .01))

-- Arguement[1] = Your frame, textbutton, etc, whatever supports transparency.
-- Arguement[2] = Your desired speed interval.

Hope this helps you along with your script.

This discussion is preserved as it was. New answers, comments, and votes are closed.