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

Localscript works in studio but not online?

Asked by 9 years ago

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.

local SetText = script.Parent.Text
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

function UpdateOldLabels(Parent)
    for i,v in pairs(Parent:GetChildren()) do
        if v.Name:sub(1,4):lower() == "line" then
            local LineNumber = v.Name:sub(5)
            if LineNumber == "12" then
                v:Destroy()
            else
                v.Name = "line"..tostring(tonumber(LineNumber) + 1)
                v.Position = v.Position - UDim2.new(0,0,0,15)
            end
        end
    end
end

--[Chat]--
script.Parent.FocusLost:connect(function(EnterPressed)
if EnterPressed then
            for _,v in ipairs(game:GetService("Players"):GetChildren()) do
            if string.find(script.Parent.Text, "/") == 1 or string.find(script.Parent.Text, " ") == 1 or script.Parent.Text == "" or (script.Parent.Text == " ") then
            script.Parent.Text = SetText
            else
            UpdateOldLabels(v:WaitForChild("PlayerGui").ServerChat.Frame)
            newchatline = Instance.new("TextLabel",v:WaitForChild("PlayerGui").ServerChat.Frame)
            newchatline.Text = "["..player.Name.."]: "..script.Parent.Text
            newchatline.Size = UDim2.new(1,0,0,18)
            newchatline.Position = UDim2.new(0,0,1,-30)
            newchatline.Font = "SourceSansBold"
            newchatline.TextColor = player.TeamColor
            newchatline.TextStrokeColor3 = Color3.new(0,0,0)
            newchatline.TextStrokeTransparency = 0.7
            newchatline.BackgroundTransparency = 1
            newchatline.BorderSizePixel = 0
            newchatline.FontSize = "Size18"
            newchatline.TextXAlignment = "Left"
            newchatline.TextYAlignment = "Top"
            newchatline.ClipsDescendants = true
            newchatline.Name = "line1"
            script.Parent.Text = SetText


          UpdateOldLabels(game:GetService("StarterGui").ServerChat.Frame)
          local clonedchat = newchatline:Clone()
          clonedchat.Parent = game:GetService("StarterGui").ServerChat.Frame
            end
    end
end
end)

mouse.KeyDown:connect(function(key)
if key == "/" then
script.Parent:CaptureFocus()
end
end)

script.Parent.FocusLost:connect(function()
wait(0.01)
script.Parent.Text = SetText
end)
0
Please tell us what you're trying to do. And it'd probably help if you added a wait(1) on the FIRST line. james24dj 90 — 9y

1 answer

Log in to vote
0
Answered by
mine248 40
9 years ago

So you have to have another script, for server side. It won't work by itself. Also, make a event called "SendMessages".

0
How? GullibleChapV2 155 — 9y
Ad

Answer this question