Broken phone code

so I am making this phone code, however, it won’t work as when I enter a message it just puts ‘enter message’ when I send a message, could someone help?
the code:
script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.values.newMessage.Value = script.Parent.Parent.Parent.thisPhone.Value … ": " … script.Parent.Parent.MessageBox.Text
local workphone = script.Parent.Parent.Parent.otherPhone.Value
local playerphone = workphone:FindFirstChild(“player”)
if playerphone.Value ~= nil then
local pp = playerphone.Value
pp.PlayerGui.PhoneGUI.ChatScreen.values.newMessage.Value = script.Parent.Parent.Parent.thisPhone.Value … ": " … script.Parent.Parent.MessageBox.Text
end
end)

function updateLine()
script.Parent.Parent.values.line10.Value = script.Parent.Parent.values.line9.Value
script.Parent.Parent.values.line9.Value = script.Parent.Parent.values.line8.Value
script.Parent.Parent.values.line8.Value = script.Parent.Parent.values.line7.Value
script.Parent.Parent.values.line7.Value = script.Parent.Parent.values.line6.Value
script.Parent.Parent.values.line6.Value = script.Parent.Parent.values.line5.Value
script.Parent.Parent.values.line5.Value = script.Parent.Parent.values.line4.Value
script.Parent.Parent.values.line4.Value = script.Parent.Parent.values.line3.Value
script.Parent.Parent.values.line3.Value = script.Parent.Parent.values.line2.Value
script.Parent.Parent.values.line2.Value = script.Parent.Parent.values.line1.Value
script.Parent.Parent.values.line1.Value = script.Parent.Parent.values.line0.Value
script.Parent.Parent.values.line0.Value = script.Parent.Parent.values.newMessage.Value
script.Parent.Parent.values.newMessage.Value = “”
end

script.Parent.Parent.values.newMessage.Changed:connect(updateLine)

It’s hard to follow the code. For now try defining all the times you use script.Parent.Parent.values as a variable so you only have to write that path once. Try to clean up any time you see yourself using the same object twice, you could be writing the path to it only once. And don’t screenshot code, it’s in the rules, and it makes it very hard for us to test the code to see what the problem is.

Ok, updated it so it is not screenshotted :slight_smile:

Can you put the script in a picture or something? I can’t really understand what you’re trying to do.

I am trying to make it so when someone types in their message to another phone the other player receives it but right now the message just says enter message when clicking send message.

For now, clean up your code. Make sure each time you reference script.Parent.Parent.values you are instead referencing a variable that stores that object. like this:

local lines = script.Parent.Parent.values

This makes the code a lot easier to read, and a lot easier for us to know what you are doing. each time you reference it after that you could just write “lines” instead of “script.Parent.Parent.values” Also make a new variable for each of the lines inside this values object, thisphone,and newmessage. After that, post your code using the preformatted text feature.

To use it, highlight over all the code you put inside your text and press this button: image

To achieve this, you need to understand how to use RemoteEvents; and as this is essentially a chat feature, you need to ensure messages are filtered too.

I suggest you read up on both of these on the wiki. You should not be trying to modify something on one client from another. You should be sending messages to the server, processing it, then returning it to it’s intended recipient.

Example #1 on that last page I’ve linked (Text and Chat Filtering) actually explains how to send a message from one client to another. You could adapt this code to fit your particular scenario.