The structure of your script checks out, but you're not checking to see if things exist before calling/writing to them.
I've done a little example (ill paste the script(s) here at the end of this answer for reference)
The code I've written checks to see if our gui elements exist before printing. If they do exist, then continue as normal if they don't exist. For example, if we misspelled LineFour
as LneFour
or even linefour
then the code will tell you that this doesn't exist in your display(s) and lets you know what display its missing.
Modified Code as follows:
ServerCode:
01 | local RadioRemoteEvents = game.ReplicatedStorage.RadioRemoteEvents |
02 | local RadioEvent = RadioRemoteEvents.RadioEvent |
04 | function DisplayMessage(Frame,Message) |
06 | local LineOne = Frame:FindFirstChild( "LineOne" ) |
07 | local LineTwo = Frame:FindFirstChild( "LineTwo" ) |
08 | local LineThree = Frame:FindFirstChild( "LineThree" ) |
09 | local LineFour = Frame:FindFirstChild( "LineFour" ) |
10 | local LineFive = Frame:FindFirstChild( "LineFive" ) |
11 | local LineSix = Frame:FindFirstChild( "LineSix" ) |
15 | local CheckTble = ( function () |
16 | local Tab = { LineOne,LineTwo,LineThree,LineFour,LineFive,LineSix } |
18 | for k,v in pairs (Tab) do |
26 | if (#CheckTble ~ = 6 ) then |
28 | error ( "Error: Malformed Display in " .. tostring (Frame) |
29 | .. " \n Object location = " .. tostring (Frame:GetFullName()) |
33 | LineSix.Text = Frame.LineFive.Text |
34 | LineFive.Text = Frame.LineFour.Text |
35 | LineFour.Text = Frame.LineThree.Text |
36 | LineThree.Text = Frame.LineTwo.Text |
37 | LineTwo.Text = Frame.LineOne.Text |
38 | LineOne.Text = Message |
41 | function ConfigMessage(Player,Message,Channel) |
42 | local RadioGui = script.Parent |
43 | local Frame = RadioGui.RadioFrame:FindFirstChild(Channel) |
44 | if (Channel ~ = nil ) then |
45 | local ConfiguredMessage = Player.Name.. ": " ..Message |
46 | DisplayMessage(Frame,ConfiguredMessage) |
48 | error ( "Channel[" .. tostring (Channel).. "] Does not exist in 'RadioGui.RadioFrame'!" ) |
52 | RadioEvent.OnServerEvent:Connect( function (Player,Message,Channel) |
53 | ConfigMessage(Player,Message,Channel) |
PlayerGui (Local Script) Code:
01 | local TextBox = script.Parent.TextBox |
02 | local SubmitBtn = script.Parent [ "Submit Button" ] |
03 | local EventCaller_Storage = game:GetService( "ReplicatedStorage" ) |
04 | local EventCaller_FDR = EventCaller_Storage:WaitForChild( "RadioRemoteEvents" , 10 ) |
05 | local EventCaller = EventCaller_FDR:WaitForChild( "RadioEvent" , 10 ) |
07 | SubmitBtn.MouseButton 1 Click:Connect( function () |
08 | local Message = TextBox.Text |
09 | EventCaller:FireServer(Message, "Channel One" ) |
Hope this helps! :)