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

My gui will only show for one player, why is that?

I want this gui to show for all players, for some reason it is only showing on one players screen. My guess is that it is something to do with the variables being reassigned before the script has a chance to run through or something like that?

**UPDATED SCRIPT THANKS TO HELP FROM chararray256 **

function mem(v)
	print(1)
	coroutine.wrap(function()	
		print(2)
		repeat wait() print("waiting") until v:FindFirstChild("PlayerGui")
		gui = v:FindFirstChild("PlayerGui").Loading.d
		print(3)
		wait()
		gui.Image = "http://www.roblox.com/asset/?id=154661376"
		gui.Visible = true
		print(4)
		for i = 1,10 do
			for a,b in pairs(introGuis) do
				print("try")
				gui.Image = "http://www.roblox.com/asset/?id=" .. b
				wait(.1)
			end
		end
		gui.Visible = false
	end)()	
end	
for i,v in pairs(game.Players:GetPlayers()) do mem(v)end	

3 answers

✓ Accepted answer

Try this:

function GiveGui(v)
    print(1)
    coroutine.wrap(function()   
        print(2)
        repeat wait() print("waiting") until v:FindFirstChild("PlayerGui")
        gui = v:FindFirstChild("PlayerGui").Loading.d
        print(3)
        wait()
        gui.Image = "http://www.roblox.com/asset/?id=154661376"
        gui.Visible = true
        print(4)
        for i = 1,10 do
            for a,b in pairs(introGuis) do
                print("try")
                gui.Image = "http://www.roblox.com/asset/?id=" .. b
                wait(.1)
            end
        end
        wait(5)
        gui.Visible = false
    end)()  
end
for i,v in pairs(game.Players:GetPlayers() do GiveGui(v) end
game.Players.PlayerAdded:connect(GiveGui)

Your script didn't work because it was ran only once, when the server was started.

7 comments

0

This isn't the full script, it is midway down the real script. And how will making it a function help, out of curiosity (could you explain your change)

0

I made the function connected to the PlayerAdded event. I made it a function to not have to write it twice (in the for loop and the connect() method.)

0

Thankyou for your answer, but one last question . Why is the playeradded there in the first place? Is it really necessary (I dont want it run on playeradded, just to all players at a certain time which is done using the for loop you provided)

0

It is neccessary as the for loop runs only once, when the server is started. I made it work so a player gets the GUI when they join as it seems you want it to work so.

0

Still does not work, I put my co-routine into a function then called it with a for loop using "v" as the argument, that way the function ran for each person BUT still only one person received the GUI

0

If it is in a LocalScript, put it in a regular script.

0

Sorry! It works! Thankyou so much!

I read somewhere that "if it's placed in a PlayerGui then it will display to one person but if it's placed in workspace then it will display to everyone

1 comment

0

But I am accessing everyones playergui, for that exact reason.

Just make the actual Gui and put it in Starter Gui.

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