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

Why is the text not changing for others?

Asked by 11 years ago
001-- NinjoOnline --
002 
003map = game.ServerStorage.Maps:GetChildren()
004 
005while true do
006 
007--------------------------
008-- Random map is chosen --
009-------------------------- 
010 
011    if game.Players.NumPlayers > 1 then
012        game.StarterGui.Main.Header.MainText.Text = "Deciding what map to play"
013        wait(3)
014        game.StarterGui.Main.Header.MainText.Text = ""
015        ranMap = math.random(1, #map)
View all 118 lines...

Ok so, this script pretty much tell the player that if their is more than 1 player on, then pick a random map. That works, but, the GUI that displays the text wont update. I started a server with 2 players, for P1 it says "You need 1 more player" and for P2 it says "Deciding what map to play". But on the server it changes and is working properly. Is something wrong, or do i need to start a real server and get a friend to play. Anyone help?

2 answers

Log in to vote
4
Answered by 11 years ago

When you want to change how a gui looks for every player, you shouldn't update the StarterGui, otherwise it won't update until they respawn. To make it change automatically, you will have to access the guis via PlayerGui which is inside each player. To do this, you will have to access each player's guis individually using a localscript. You will then need to use a server script to clone the map into the game, otherwise you'd end up crashing the game if each localscript were to do that.

01player = game.Players.LocalPlayer
02maintext = player.PlayerGui.Main.Header.MainText
03 
04 
05while wait() do
06 if game.Players.NumPlayers > 1 then
07    maintext.Text = "Deciding what map to play"
08        wait(3)
09        maintext.Text = ""
10        maintext.Text = "Map Chosen: " .. _G.mapChosen.Name
11        wait(2)
12        maintext.Text = ""
13        wait(2)
14    else maintext.Text = "You need 1 more player"
15    end

This above script should be localscript and placed in the startergui.

01map = game.ServerStorage.Maps:GetChildren()
02_G.mapChosen = nil
03 
04while wait() do
05    if game.Players.NumPlayers > 1 then
06        wait(2)
07            ranMap = math.random(1, #map)
08            _G.mapChosen = map[ranMap]
09        wait(3)
10        mapChosenClone = _G.mapChosen:Clone()
11            mapChosenClone.Parent = game.Workspace.MapHolder
12    end
13end

This above script should be a server script and placed in Workspace.

This may not entirely work, but this should be helpful.

------------------------ Update: Based on the fact that you posted the whole script now, I have made it so that it should work now as is. ------------------------

001-- NinjoOnline --
002 
003map = game.ServerStorage.Maps:GetChildren()
004 
005while true do
006 
007--------------------------
008-- Random map is chosen --
009-------------------------- 
010 
011    if game.Players.NumPlayers > 1 then
012        for i,v in pairs(game.Players:GetPlayers()) do
013        v.PlayerGui.Main.Header.MainText.Text = "Deciding what map to play"
014    end
015        wait(3)
View all 126 lines...
0
No this may or may not work. I have 1 main script. The main script chooses map, tps everyone, and all that. I need it so it will go in one script and not be a local. NinjoOnline 1146 — 11y
0
and what is a server script? NinjoOnline 1146 — 11y
0
I have just updated the script to the full script. NinjoOnline 1146 — 11y
1
I have added an updated section to the end of the post. It should work now. If it doesn't, it must be something that you have done. FearMeIAmLag 1161 — 11y
View all comments (3 more)
0
still dosent work NinjoOnline 1146 — 11y
0
It can't be me. This is the only script. It has always worked, choosing map, etc. Just the text. It is defiantly main.Header.MainText, etc. It just dosent update at all NinjoOnline 1146 — 11y
0
Are you sure you're not accessing the gui wrong or something? Open the game in play solo in studio and tell me what the output says. FearMeIAmLag 1161 — 11y
Ad
Log in to vote
-2
Answered by 11 years ago

You would actually want to use this function:

01function M(mesag,tim,sho)
02    for i,v in pairs(game.Players:GetChildren()) do
03        if v.PlayerGui and v.PlayerGui.Main and v.PlayerGui.Main.Header.MainText then
04            v.PlayerGui.MainGui.MESG.Visible = true
05        v.PlayerGui.Main.Header.MainText.Text = mesag
06 
07        end
08    end
09wait(tim)
10for i,v in pairs(game.Players:GetChildren()) do
11        v.PlayerGui.Main.Header.MainText.Text = sho
12        end
13end

Just when you call the function do this

1M("Insert message here between parenthesis", 4--[[time you want it to show]], true--[[if you want it to show or disappear after the message is done being showed]])

so just in case you didn't get that, use parenthesis to put in text first, put a comma, how long you want it to show, another comma, and then true or false for it to become hidden or stay visible. I have my friend edit the script for you.

001-- NinjoOnline --
002--Edited by luis91899--
003 
004function M(mesag,tim,sho)
005    for i,v in pairs(game.Players:GetChildren()) do
006        if v.PlayerGui and v.PlayerGui.Main and v.PlayerGui.Main.Header.MainText then
007            v.PlayerGui.MainGui.MESG.Visible = true
008        v.PlayerGui.Main.Header.MainText.Text = mesag
009 
010        end
011    end
012wait(tim)
013for i,v in pairs(game.Players:GetChildren()) do
014        v.PlayerGui.Main.Header.MainText.Text = sho
015        end
View all 132 lines...

Hope this was helpful. :P

0
so this will fix it? NinjoOnline 1146 — 11y
0
dosent work, the else on line 128 is red underlined NinjoOnline 1146 — 11y
0
Next time check to make sure NinjoOnline 1146 — 11y

Answer this question