-- local script local repStorage = game:GetService("ReplicatedStorage") local Broadcast = repStorage:WaitForChild("Broadcast") script.Parent.MouseButton1Click:Connect(function(player) local MessageBox = script.Parent.Parent.MessageBox local CharacterValue = script.Parent.Parent.CharacterLabel.Characters.Value local CharactersLeftValue = script.Parent.Parent.CharacterLabel.CharactersLeft.Value local MaxCharactersValue = script.Parent.Parent.CharacterLabel.MaxCharacters.Value Broadcast:FireServer(player, MessageBox, CharactersLeftValue, CharacterValue, MaxCharactersValue) end)
and
game.ReplicatedStorage.Broadcast.OnServerEvent:Connect(function(player, MessageBox, CharactersLeftValue, CharacterValue, MaxCharactersValue) for i,v in pairs(game.Players:GetPlayers()) do local InstanceGui = v.PlayerGui.InstanceGui local MessageFrame = Instance.new("Frame", InstanceGui) MessageFrame.Name = "MessageFrame"..math.random(1,1000) MessageFrame.Size = UDim2.new(0.2, 0,0.2, 0) MessageFrame.Position = UDim2.new(0.029, 0,0.703, 0) MessageFrame.BackgroundColor3 = Color3.fromRGB(102,102,102) MessageFrame.BorderSizePixel = 3 MessageFrame.BackgroundTransparency = 0 local AspectRatio = Instance.new("UIAspectRatioConstraint", MessageFrame) AspectRatio.AspectRatio = 1.5 local Title = Instance.new("TextLabel", MessageFrame) Title.Name = "Title" Title.Size = UDim2.new(1, 0,0.2, 0) Title.Position = UDim2.new(0, 0,0, 0) Title.BorderSizePixel = 3 Title.Font = Enum.Font.GothamBold Title.Text = "Server Broadcast" Title.TextColor3 = Color3.fromRGB(255,255,255) Title.BackgroundColor3 = Color3.fromRGB(102,102,102) Title.TextScaled = true local Text = Instance.new("TextLabel", MessageFrame) Text.Name = "Text" Text.Size = UDim2.new(1, 0,0.798, 0) Text.Position = UDim2.new(0, 0,0.2, 0) Text.BorderSizePixel = 0 Text.Font = Enum.Font.GothamBold Text.Text = tostring(MessageBox.Text) -- Mainly this part Text.TextColor3 = Color3.fromRGB(255,255,255) Text.BackgroundColor3 = Color3.fromRGB(102,102,102) Text.TextScaled = true Text.BackgroundTransparency = 1 MessageBox.Text = "" -- this a bit CharactersLeftValue = MaxCharactersValue CharactersLeftValue = 0 MessageBox.TextEditable = true -- And this wait(5) MessageFrame:Remove() end end)
Pretty much here, trying to make a server broadcast thing
When you are using :FireServer()
you don't put player as an argument. Because you did it all the receiving arguments are mixed up.
FireServer(Player,Text) --Wrong ....OnServerEvent:Connect(function(Player,Text) -- In this case Text will actually be the player FireServer(Text) --Corect ....OnServerEvent:Connect(function(Player,Text) -- In this case Text will actually be text
FireServer automatically sends the player to the server, there's no need for manually doing that, basically what you have done now is sending the second argument on the server MessageBox
, which gets a value from the client which is the player.
Also I wouldn't physically send the TextBox over the network, it'll only know how to transfer instances if both the Server and Client know of the instance existance. I'd rather just send the MessageBox.Text
which is the text data of the textbox.
Edit:
I would also like to point out how absolutely pointless this part is
tostring(MessageBox.Text)
The text property is already of type string, there's no need to turn it into a string.