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

Why can't I clone a gui to PlayerGui through script?

I made a simple "script" so that every player in a server sees a gui that gets cloned to PlayerGui for a certain amount of time, but it doesn't appear why?

wait(5)
game.ReplicatedStorage.Continued:Clone().Parent = game.Players.LocalPlayer.PlayerGui
wait(20)
game.Players.LocalPlayer.PlayerGui.Continued:Destroy()

2 comments

1

if its a server script it cant see LocalPlayer

0

so do I set it as local script

1 answer

To do so, you need for loops, this is how to do so

for i,v in pairs(game.Players:GetChildren()) do
	if v.Character then
		wait(5)
		game.ReplicatedStorage.Continued:Clone().Parent = v.PlayerGui
		wait(20)
		v.PlayerGui.Continued:Destroy()
	end
end

3 comments

0

-1 for extremely inefficient and incorrect code, PlayerAdded cuts you some real slack here, or even GetPlayerFromCharacter()

0

so this script doesn't work?

0

The loop will immediately error out if Character is nil

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