Invalid member of Frame, .OnServerEvent problem

I tried to change the text of a text label in a frame but got this error instead
announcement is not a valid member of Frame "Players.Egliod.PlayerGui.Eric.Announcement

My code and frame child and parents are all correct, I think.

image

local event = game.ReplicatedStorage:WaitForChild("Intercom")

local finished = game.ReplicatedStorage:WaitForChild("announcementFinished")

event.OnClientEvent:Connect(function(text)

script.Parent.Parent.Announcement.Visible = true

script.Parent.Parent.Announcement.announcement = text

task.wait(10)

script.Parent.Parent.Announcement.Visible = false

finished:FireServer()

end)

You seem to be missing a .Text in what I quoted above. It should be “script.Parent.Parent.Announcement.announcement.Text = text”.

You are right, I was missing .Text, but now I have another problem.
Unable to assign property Text. string expected, got Instance
I am pretty sure I know where the problem is, but I don’t know why.
My script uses remote events to send the text to the server and then back to display for everyone.

Client remote event send:

local event = game.ReplicatedStorage:WaitForChild("Intercom")

script.Parent.Say.Activated:Connect(function()

local text = script.Parent.Text.Text

event:FireServer(text)

end)

SERVER SIDE--------------------- (idk why the lua block doesn't break, sorry)


local event = game.ReplicatedStorage:WaitForChild("Intercom")


event.OnServerEvent:Connect(function(text)

	event:FireAllClients(text)


end)

I am passing the text I got from the textbox.

Looking at it, I most definitely am not keen regards naming Text Labels, Buttons, or Boxes as “Text” because Text is considered as a property under Luau, and that’s what I feel could be causing the problem as well. I would recommend renaming it something else just to rule it out.

EDIT: I did tostring(), now on text i get my player name and not the textbox text.

The first parameter in a .OnServerEvent function is the player instance. So this is what your code should look like:

local event = game.ReplicatedStorage:WaitForChild("Intercom")


event.OnServerEvent:Connect(function(player,text)
    -- the 'player' is just for the server to know which client sent the request, the next one is the parameter passed,
	event:FireAllClients(text)


end)
1 Like

If I could, I would put both of your posts as solutions.

Thanks! This was the problem! This fixed it!

1 Like

Thank you! I did that. Definitely easier to read the script.

I would most definitely say that because the topic of this post is about an Invalid Frame, you should select the post that does address this problem rather than something that isn’t fully in relation to the title above. It could be misleading and people that may look into this solution and find a solution that doesn’t address the specific concern could cause confusion.

Changed the title, Thanks! I hope it would be better now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.