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

Why do I only see this frame in roblox studio but not when I play the game?

I'm trying to make a fading blindness effect where a black frame over your screen slowly fades away. The way i'm trying to achieve this is with the background transparency of the frame, the code I have for this is shown here:

inviswall = workspace.Hall.InvisWall
blindness = game.StarterGui.ScreenGui.Blindness

function ShowWall()
    print("Touched")
    inviswallTransparency = 0
    print("Wall visible.")
    wait(5)
    blindness.BackgroundTransparency = 0
    wait(5)
    print("Unblinding.")
    for i = 0, 1, 0.1 do
        blindness.BackgroundTransparency = i
    end
end)

workspace.Hall.InvisTouch.Touched:Connect(ShowWall)

When I play the game the frame doesn't seem to show. When I walk over the part that runs the function I can see the transparency of the frame changing in explorer but nothing changes in the game.

1 answer

✓ Accepted answer

It's the same confusion I have when I was starting so I'll explain you

The function of the StarterGui is to copy itself into the Player's Gui when the game loads

So the real Gui is not in StarterGui it is in Player.PlayerGui

First: The gui can only be changed with a local script

Second: The local script has "LocalPlayer" to refers to your player

Create a local script in StarterGui or StarterPlayerScripts and put

inviswall = workspace.Hall.InvisWall
Player = game.Players.LocalPlayer --This is your player
PlayerGui = Player:WaitForChild("PlayerGui") --This is your local Gui I used WaitForChild because the Gui takes time to load
ScreenGui = PlayerGui:WaitForChild("ScreenGui") --Same here
blindness = ScreenGui:WaitForChild("Blindness") --And here


function ShowWall()
    print("Touched")
    inviswallTransparency = 0
    print("Wall visible.")
    wait(5)
    blindness.BackgroundTransparency = 0
    wait(5)
    print("Unblinding.")
    for i = 0, 1, 0.1 do
        blindness.BackgroundTransparency = i
    end
end)

workspace.Hall.InvisTouch.Touched:Connect(ShowWall)

You can also put your local script inside ScreenGui in StarterGui and it will work because the script will also be copied and runned inside the player gui so u can use script.Parent to refer to the ScreenGui and script.Parent.Blindness for the Blindness Frame

Sorry for my english hope you understand me

2 comments

0

You should also use local variables.

0

Yes i use them but i just copied and pasted the script above

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