Roblox Code Help

So I am making a roblox game, and when i click this button it is supposed to send the text from the textbox through a remote event and into a script that says it in chat, but it just prints a blank space in chat

Well, we need to see your code to help you. A screenshot of the explorer would also be nice, and if you could record what happens when you click the button, that’d be great.

i made some edits to the topic, also the scripts and a screenshot is below

script 1:

script.Parent.MouseButton1Click:Connect(function()
	local message = script.Parent.Parent.MessageBox.Text
	local npc = script.Parent.Parent.NameBox.Text
	for i,player in pairs(game.Players:GetChildren()) do
		player.ChatToShow.Value = message
		game.ReplicatedStorage.SendMessage:FireClient(player, npc)
	end
end)

script 2:

game.ReplicatedStorage.SendMessage.OnClientEvent:Connect(function(playername)
	local messagetochat = script.Parent.Parent.ChatToShow.Value
	if game.Workspace.NPCS:FindFirstChild(playername) then
		game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
			Text = `[{playername}]: {messagetochat}`;
			Color = Color3.new(1, 1, 1);
		})
	end
end)

(script 2 is a local script inside of the players player scripts folder)

screenshot:

Ok, so where is ChatToShow in your explorer? And do you get any errors in the output?

I do not get any errors in the output and chat to show automatically adds to every player when they join from a script that has the contexts of this:

game.Players.PlayerAdded:Connect(function(player)
	local newvalue = Instance.new("StringValue")
	newvalue.Name = "ChatToShow"
	newvalue.Parent = player
end)

So where is script 1?

oh I forgot to tell you, script one is in the chat button script 2 is in starter player scripts, and the one that adds the values is in serverscriptservices

you still there? @QwertyQwerty88

also the name i type in does exist in the npcs folder in workspace

Script 1 has to be a local script then, a server script won’t work with GUIs

it seems like that did not work.

Hi guys i have fixed the problem, the value changer was a localscript, as i used values so i made the button script a localscript firing a server event and it fixed it.

1 Like

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