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)
COMMUNITY QUESTION
This script works in studio but not online?
1 answer
You need to use a LocalScript, which runs locally.
"LocalPlayer" directs a LocalScript to the Player object that the LocalScript is using, but a server script(Simply called, a "script".) cannot use it.
I may be wrong, but I've checked the script exactly five times, and there seems to be no problem if it's a LocalScript, and you said, "this script", so I'm guessing it's a script.
A better answer may be found here: http://wiki.roblox.com/index.php?title=LocalScript
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I'm using a localscript.