Localscript works in studio but not online?
I have a ScreenGui named 'ServerChat' a frame inside and a textbox as a chatbar. The chat's only clone into the player's playergui and not startergui or other player's playerguis.
01 | local SetText = script.Parent.Text |
02 | local player = game.Players.LocalPlayer |
03 | local mouse = player:GetMouse() |
05 | function UpdateOldLabels(Parent) |
06 | for i,v in pairs (Parent:GetChildren()) do |
07 | if v.Name:sub( 1 , 4 ):lower() = = "line" then |
08 | local LineNumber = v.Name:sub( 5 ) |
09 | if LineNumber = = "12" then |
12 | v.Name = "line" .. tostring ( tonumber (LineNumber) + 1 ) |
13 | v.Position = v.Position - UDim 2. new( 0 , 0 , 0 , 15 ) |
22 | for _,v in ipairs (game:GetService( "Players" ):GetChildren()) do |
23 | if string.find(script.Parent.Text, "/" ) = = 1 or string.find(script.Parent.Text, " " ) = = 1 or script.Parent.Text = = "" or (script.Parent.Text = = " " ) then |
24 | script.Parent.Text = SetText |
26 | UpdateOldLabels(v:WaitForChild( "PlayerGui" ).ServerChat.Frame) |
27 | newchatline = Instance.new( "TextLabel" ,v:WaitForChild( "PlayerGui" ).ServerChat.Frame) |
28 | newchatline.Text = "[" ..player.Name.. "]: " ..script.Parent.Text |
29 | newchatline.Size = UDim 2. new( 1 , 0 , 0 , 18 ) |
30 | newchatline.Position = UDim 2. new( 0 , 0 , 1 ,- 30 ) |
31 | newchatline.Font = "SourceSansBold" |
32 | newchatline.TextColor = player.TeamColor |
33 | newchatline.TextStrokeColor 3 = Color 3. new( 0 , 0 , 0 ) |
34 | newchatline.TextStrokeTransparency = 0.7 |
35 | newchatline.BackgroundTransparency = 1 |
36 | newchatline.BorderSizePixel = 0 |
37 | newchatline.FontSize = "Size18" |
38 | newchatline.TextXAlignment = "Left" |
39 | newchatline.TextYAlignment = "Top" |
40 | newchatline.ClipsDescendants = true |
41 | newchatline.Name = "line1" |
42 | script.Parent.Text = SetText |
45 | UpdateOldLabels(game:GetService( "StarterGui" ).ServerChat.Frame) |
46 | local clonedchat = newchatline:Clone() |
47 | clonedchat.Parent = game:GetService( "StarterGui" ).ServerChat.Frame |
53 | mouse.KeyDown:connect( function (key) |
55 | script.Parent:CaptureFocus() |
59 | script.Parent.FocusLost:connect( function () |
61 | script.Parent.Text = SetText |