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

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

Asked by
Xuvia 0
5 years ago
Edited 5 years ago

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.

0
Oh, nevermind, but it seems to now disappear if you die or reach a certain point... Xuvia 0 — 5y
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? g1o2r3d4a5n6 350 — 5y
0
Just add the GUI to StarterGui, that's why it exists. SirLuisFonsi 9 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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!

Ad

Answer this question