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

How can I fix this fading script to work while the player is seated?

Asked by 4 years ago

I am trying to make my fading script work while the player is seated. When the player is unseated it seems to be working fine.

Here is the 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)

Please look at the two videos to get a better understanding of what my problem is. Any help appreciated, thanks!

Answer this question