String expected, got nil

Hello! I am trying to make a annoument system and I am having some issue.

Issue:


Workspace:

Code:
Local script

local valueputthough = script.Parent.Parent.Value.Value

script.Parent.MouseButton1Click:Connect(function(Player)
	
	script.Parent.Parent.Value.Value = script.Parent.Parent.AddText.Text
	
	wait(1)
	game.ReplicatedStorage.EventsGUI.Message:FireServer(valueputthough)
end)

Server script:

game.ReplicatedStorage.EventsGUI.Message.OnServerEvent:Connect(function(Message)

script.Parent.Text = Message

script.Parent.Parent.Parent.Main.Visible = true

end)

the first parameter of a remote event is always the player.

game.ReplicatedStorage.EventsGUI.Message.OnServerEvent:Connect(function(player, Message)

Try and use this.

game.ReplicatedStorage.EventsGUI.Message.OnServerEvent:Connect(function(player, Message)

script.Parent.Text = Message

script.Parent.Parent.Parent.Main.Visible = true

end)

Give the solution to Kaiden if it is the solution because he replied first.

I did that this comes up


But no message in it

this is because you are referencing the value at the beginning of the script, so you should update it through this:

local valueputthough = script.Parent.Parent.Value

script.Parent.MouseButton1Click:Connect(function(Player)
	
	script.Parent.Parent.Value.Value = script.Parent.Parent.AddText.Text
	
	wait(1)
	game.ReplicatedStorage.EventsGUI.Message:FireServer(valueputthough.Value)
end)

Did you set valueputthough to what you want it to be when you fire the event?

Thankyou for helping me with my problem!

sorry for asking this but it works the first time just good it sends the message and displays it but when you press the close button and then send another one it just does not work no errors or anything

Are you changing the Value at all? If so then it should work.

Example: I say this in where you put the message: Hello all then it will show up thats fine ok then when they click ok and I do another saying: Bye all, it does not show up the gui

That is because in the beginning you set the value so you have to change the value to get a different result.

It takes it out from what is said in the thing here I got an example: https://gyazo.com/2063e505120c0f6067339ef477af8efd

this is because you close the gui locally and not on the server side. So, when the GUI is trying to be turned visible on the server, the server views it as already open. So, either change the closing script to a server script or, add an extra line like this on the server part:

game.ReplicatedStorage.EventsGUI.Message.OnServerEvent:Connect(function(player, Message)

script.Parent.Text = Message
script.Parent.Parent.Parent.Main.Visible = false
script.Parent.Parent.Parent.Main.Visible = true

end)

Wouldn’t you want to check if it is open or closed like this?

game.ReplicatedStorage.EventsGUI.Message.OnServerEvent:Connect(function(player, Message)
	
	script.Parent.Text = Message
	
	if script.Parent.Parent.Parent.Main.Visible == false then
		
		script.Parent.Parent.Parent.Main.Visible = true
	else
		
		script.Parent.Parent.Parent.Main.Visible = false
	end
end)

Thanks for making it work for me! Have a good day.

1 Like