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

I've been trying to follow a video for screengui, how to resolve it?

But whenever I put it into ServerStorage it disappears? Even when I added:

game.Players.PlayerAdded:Connect(function(plr)
	local Tracker = Instance.new("IntValue")
	Tracker.Name = "Tracker"
	Tracker.Parent = plr
	**local Clone = game.ServerStorage.ScreenGui:Clone()
	Clone.Parent = plr.PlayerGui**
end)

I even tried copy and pasting another screengui into ServerStorage but it messes it up... and when I asked someone I know who develops, they said whenever ROBLOX does update, GUIs won't work. So what am I supposed to do?? I'm still new to this stuff.

Edit: the ** were supposed to bold but I guess something went wrong. Anyways, that was the part I added.

3 comments

0

Oh, nevermind, but it seems to now disappear if you die or reach a certain point...

0

what are you even trying to do? the script you posted has the same effect as just putting the screen gui in starter gui service without using any script so why not do that?

0

Just add the GUI to StarterGui, that's why it exists.

1 answer

Hello!

First, now that this script works the issue seems to be it disappears if you die.

There are a couple of ways to solve this. We can use an event that detects when the player's character respawns so that you can add the GUI back.

Here is your edited code:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char) -- this will run when character respawns
    local Tracker = Instance.new("IntValue")
    Tracker.Name = "Tracker"
    Tracker.Parent = plr
    local Clone = game.ServerStorage.ScreenGui:Clone()
	Clone.ResetOnSpawn = false
    Clone.Parent = plr.PlayerGui
	end)
end)

To improve this, we can add a Condition Statement to check if the player already has the GUI to avoid having multiple of the same Gui. To do this, let's name the GUI.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char) -- this will run when character respawns
    local Tracker = Instance.new("IntValue")
    Tracker.Name = "Tracker"
    Tracker.Parent = plr
	if plr:WaitForChild('PlayerGui'):FindFirstChild('AnyNameHere') then return end -- If there is already a gui called AnyNameHere do not continue basically
    local Clone = game.ServerStorage.ScreenGui:Clone()
	Clone.ResetOnSpawn = false
	Clone.Name = 'AnyNameHere'
    Clone.Parent = plr.PlayerGui
	end)
end)

Now you can go try!

Hopefully, this helped you.

Best of luck developer!

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