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

GUI won't load in sometimes into the player?

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.

5 comments

0

Where is the script?

0

You don't see it? It is in the beginning.

0

I mean, where is it placed? ServerScriptStorage?

0

It is placed in workspace, a server script.

0

read my answer.

2 answers

✓ Accepted answer

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.

1 comment

0

Thanks.

-- 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]]

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