I sort of lied, this is a two part question.
Info:I know this is in a global function, I call it in another script. Also the part with the Screen Gui is alright so that you shouldn't need to worry about.
_G["survivor"] = function() for i,v in pairs(game.Players:GetPlayers()) do v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true v.PlayerGui.ScreenGui.survivor.Visible = true wait(4) v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false v.PlayerGui.ScreenGui.survivor.Visible = false wait(1) end end
1) How can I eliminate the excessive amounts of the same lines. I'm sure you can use a for loop but, I am not very good with them so if anyone can explain that would be great.
2)Whenever I test it with another player it will show up on the first person's screen, wait for it to finish, then goes to the next person, until it has done all the players. Is there a way to make it appear all at one time?
I really hope this makes some sense. Thanks :)
If you have two seperate loops, It will make everyone's visible, Then wait 4 seconds and make it invisible.
_G["survivor"] = function() for i,v in pairs(game.Players:GetPlayers()) do v.PlayerGui.ScreenGui.survivor.Visible = true end wait(4) for i,v in pairs(game.Players:GetPlayers()) do v.PlayerGui.ScreenGui.survivor.Visible = false end end
Im not sure why you had to repeatable spam those lines of code, This should work if there is only one frame.
Well if you want to do this for more than one player at a time you could use threads
Threads allow you to run multiple pieces of code at once
In ROBLOX there is a built in function called Spawn that allows you to create threads
Example:
In this first code I don't use threading so it prints every 2 seconds
for i = 1, 10 do print(i) wait(2) print(i) end
In the second example I use threading so it prints all at once instead of waiting 2 seconds in between each one
for i = 1,10 do Spawn(function() print(i) wait(2) print(i) end) end
So just apply threading to your code and it should work.
Also there is no reason you should need to set the same value 10 times it will stay the same you only need to set it once.