GUI not working

Hi all

i am making a horror game and i have made something like a transition GUI
in which when the player touches the bed a frame and textbox appear with the text sleeping.But for some reason that script is not working!

Here’s the script

local Sign = game.StarterGui.Sleeping.TextBox
local Background = game.StarterGui.Sleeping.Frame

game.Workspace.DoubleBed.MeshPart.Touched:Connect(function()
	Background.Visible = true
	Sign.Visible = true
	wait(4)
	Background.Visible = false
	Sign.Visible = false
end)

The Gui wont appear at all

2 Likes

This will run multipile times whenever character touches the part, you can add toggle variable boolean so it runs only 1 time.

This might or not a solution and reliable, reply to me if is it works.

1 Like

You need to use Remote Events, not force the GUI to fade using a server script. Whenever a player touches the bed, a remote event is being fired. The GUI will receive that event and fade properly.

Editing the game.StarterGui won’t change a thing. If you really want to edit the player’s GUI with a server script, you should be using the player.PlayerGui.Sleeping.Frame path.

2 Likes

You can’t change GUIs from StarterGui

2 Likes

The starter gui is just a service where you put the guis and the guis will get cloned to the player gui when the player joins. As @InfiniteBlackPIX mentioned, you should use the player.PlayerGui

2 Likes

I tried the player.PlayerGui.Sleeping.Frame thing but it is showing the orange error line.and still dose not work

2 Likes

Are you aware that you have to get the player from the touch event?

game.Workspace.DoubleBed.MeshPart.Touched:Connect(function(hit)
    local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
    if player then
        
    local Sign = player.PlayerGui.Sleeping.TextBox
    local Background = player.PlayerGui.Sleeping.Frame

    Background.Visible = true
	Sign.Visible = true
	wait(4)
	Background.Visible = false
	Sign.Visible = false


    
    end
end)
2 Likes

OMG!!! It is finally working thank you SOOO much.The menu and chat button are cutting it which looks annoying is there a way to stop that?

1 Like

Just toggle between which you make visible and which you make invisible.

1 Like

Not sure if it will work but try player.PlayerGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false). This will disable all the CoreGui elements (chat + leaderboard).

1 Like

it dose not work but no worries i really dont need it

1 Like