Remote event paramters arent printing anything

I am trying to achieve a dialogue system. It’s very choppy so don’t worry about how badly i wrote the code just help with with the problem. In my dialogue script when i press a button it fires a remote event to the server passing a string containing which button was fired. On the recieving end of the function, I have a simple print statement so i can make sure it is recieving the function correctly. However when it prints, nothing is printed.
this is my script inside the gui

local RS = game:GetService("ReplicatedStorage")

local Reponse1 = script.Parent.Response.Response1
local Reponse2 = script.Parent.Response.Response2
local Reponse3 = script.Parent.Response.Response3

Reponse1.Activated:Connect(function()
	RS.Remotes.Dialogue:FireServer("", "response1")
end)
Reponse2.Activated:Connect(function()
	RS.Remotes.Dialogue:FireServer("", "response2")
end)
Reponse3.Activated:Connect(function()
	RS.Remotes.Dialogue:FireServer("", "response3")
end)

this is my script inside the npc you click to interact with

local RS = game:GetService("ReplicatedStorage")
local d1 = "is this working"
local d2 = "good"
local d3 = "oh ok"
local b1 = "yes"
local b2 = "no"
local b3 = "bye"
local currentd = "start"
script.Parent.ClickDetector.MouseClick:Connect(function(player)
	print("clicked")
	player.PlayerGui.Dialogue.Enabled = true
	
	player.PlayerGui.Dialogue.Response.Response1.Text = b1
	player.PlayerGui.Dialogue.Response.Response2.Text = b2
	player.PlayerGui.Dialogue.Response.Response3.Text = b3
	RS.Remotes.Dialogue.OnServerEvent:Connect(function(player, response)
		print(response)
	end)
	if currentd == "start" then
		player.PlayerGui.Dialogue.DialogueContainer.Dialogue.Text = d1
	end
end)

help

2 Likes
Reponse1.Activated:Connect(function()
	RS.Remotes.Dialogue:FireServer(Response1)
end)
Reponse2.Activated:Connect(function()
	RS.Remotes.Dialogue:FireServer(Response2)
end)
Reponse3.Activated:Connect(function()
	RS.Remotes.Dialogue:FireServer(Response3)
end)

Try this in the bottom part of the gui script.

1 Like

You are sending two arguments through the remote events, of which the first is empty:

Reponse1.Activated:Connect(function()
	RS.Remotes.Dialogue:FireServer("", "response1")
end)

The server receives, automatically, the player as the first argument, and then the arguments that you chose to send.

So, when you tried to print response in:

RS.Remotes.Dialogue.OnServerEvent:Connect(function(player, response)
	print(response)
end)

You are in fact, printing the empty string you sent.

Here’s what the OnServerEvent should look according to what you’re sending:

remoteEvent.OnServerEvent:Connect(function(player, argument1, argument2)
    print(player.Name) --Output: [username]
    print(argument1) --Output:
    print(argument2) --Output: response1
end)
3 Likes

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