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

GUI won't load in sometimes into the player?

Asked by 5 years ago
game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            Voting = game.ReplicatedStorage.Voting:Clone()
            wait(10)
    Voting.Parent = player.PlayerGui
        end)
    end)
end)

So, I tried making this script in hope it will re add the GUI to the player. (The GUI is cloned from replicated storage). But it only adds it to 1 player. I can't find what the problem is. Thanks.

0
Where is the script? Delude_d 112 — 5y
0
You don't see it? It is in the beginning. Thesquid13 301 — 5y
0
I mean, where is it placed? ServerScriptStorage? Delude_d 112 — 5y
0
It is placed in workspace, a server script. Thesquid13 301 — 5y
0
read my answer. Delude_d 112 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

If you are trying to make a Gui persist through death, they have this relatively new property called ResetOnSpawn when you can check true or false from the property menu.

But if you are wondering why the Gui only goes into one player, it is because it is only going to one player here: Voting.Parent = player.PlayerGui

You would need to do something like this,

for _,get in pairs(game.Players:GetChildren()) do
    if get.PlayerGui then
        game.ReplicatedStorage.Voting:Clone().Parent = get.PlayerGui
    end
end

If you are on Filtering Enabled however, I believe you would need to set up a RemoteEvent to go from the client that died, to the server, then back to the other clients. This is because you can't access another client's (player) PlayerGui.

0
Thanks. Thesquid13 301 — 5y
Ad
Log in to vote
0
Answered by
Delude_d 112
5 years ago
Edited 5 years ago
-- Server scripts cannot access a player's PlayerGui
--[[ Use a localscript to define the character then the died event and then clone the gui using local script. Put the local script in playerGui btw]]

Answer this question