How would you go about affecting everyone's UI? My script only runs for one person?
Asked by
5 years ago Edited 5 years ago
Hello,
This script is supposed to run for all players in the game, but it only seems to run for the latest person that joined? It's strange, and I'm starting to feel like I may be on the wrong path? The script is supposed to affect everyone's UI. How would you go about fixing my script? Or is there a better approach?
I'm quite new to scripting, so all help and explanations are very much appreciated.
This is a server script in ServerScriptService. When there is only one player in the game, it works fine.
Here is my current script:
003 | local RepStorage = game:GetService( "ReplicatedStorage" ) |
004 | local Players = game:GetService( "Players" ) |
006 | local TextGui = script.NPCtext:Clone() |
007 | local ServerText = script.ServerText:Clone() |
008 | local PlayerText = script.PlayerText:Clone() |
009 | local TextSound = script.TextSound |
014 | Players.PlayerAdded:Connect( function (player) |
015 | TextGui.Parent = player.PlayerGui |
016 | ServerText.Parent = player.PlayerGui |
017 | PlayerText.Parent = player.PlayerGui |
020 | TextGui.Frame.Visible = false |
021 | ServerText.Frame.Visible = false |
022 | PlayerText.Frame.Visible = false |
026 | function ServerTextAni() |
027 | local GuiType = ServerText |
029 | GuiType.Frame.Visible = true |
030 | for i = 1 , #GuiText do |
031 | GuiType.Frame.Text.Text = string.sub(GuiText, 1 , i) |
036 | GuiType.Frame.Text.Text = "" |
037 | GuiType.Frame.Visible = false |
041 | local GuiType = TextGui |
043 | GuiType.Frame.Visible = true |
044 | for i = 1 , #GuiText do |
045 | GuiType.Frame.Frame.Text.Text = string.sub(GuiText, 1 , i) |
050 | GuiType.Frame.Frame.Text.Text = "" |
051 | GuiType.Frame.Visible = false |
054 | function PlayerTextAni() |
055 | local p = Players:GetPlayers() |
056 | local selected_value = math.random( 1 ,#p) |
057 | local UserId = p [ selected_value ] .Name |
058 | local GuiType = PlayerText |
061 | local player = p [ selected_value ] |
062 | local thumbnailType = Enum.ThumbnailType.HeadShot |
063 | local thumbnailSize = Enum.ThumbnailSize.Size 420 x 420 |
065 | local content, isReady = Players:GetUserThumbnailAsync(player.UserId, thumbnailType, thumbnailSize) |
067 | GuiType.Frame.Player.Image = content |
069 | GuiType.Frame.Visible = true |
070 | for i = 1 , #GuiText do |
071 | GuiType.Frame.Frame.Text.Text = string.sub(GuiText, 1 , i) |
076 | GuiType.Frame.Frame.Text.Text = "" |
077 | GuiType.Frame.Visible = false |
081 | Text = "Players are loading, please wait..." |
085 | Text = "Hello everyone, welcome to Clarenval Island!" |
088 | Text = "I'm Nathan Eyler, your tour guide for the week!" |
091 | Text = "Ugh, finally! It took such a long time!" |
094 | Text = "I'm exhausted!" |
097 | Text = "I can see that all of you are tired, don't worry; the cabins are not far away." |
100 | Text = "Come with me, I'll show you the way." |
103 | Text = "Follow your tour guide, Nathan. Be on the look-out for useful items!" |