RemoveEvent Values Sending Nil?

So, I’ve been attempting to make a dialogue system. I tried giving it functionality between both the client and the server. But that’s where things got a little weird.

So here’s the client sending a RemoteEvent to the server with all the dialogue parameters:

dialogue:FireServer(3, "Good morning, Bikini Bottom! Another beautiful day to work...",, 30.3439865, 241.909363, -0.630638838, -0.0015594518, -0.776074946, 0, 0.999997973, -0.00200940482, 0.776076496, -0.00126720872, -0.630637586))
dialogue:FireServer(3, "Objective: Head to the Krusty Krab!",, 12.3791313, -228.366959, -0.999915302, 0.0014154258, 0.012938994, 0, 0.994069815, -0.108743548, -0.013016182, -0.108734339, -0.993985593))

Then, the server receives the Event. The server then transfers parameters to the client, where the dialogue is displayed.

Server transfer:

local dial = game.ReplicatedStorage:WaitForChild("DialogueClient")

dial.OnServerEvent:Connect(function(player, duration, text, cframe)
	-- CFrame not required for execution of the dialogue
	if cframe ~= nil then
		print("SERVER:", player, duration, text, cframe)
		dial:FireClient(player, duration, text, cframe)
		dial:FireClient(player, duration, text)

Client Handler:

local event = game.ReplicatedStorage:WaitForChild("DialogueClient"	)
local deb = false

event.OnClientEvent:Connect(function(duration, text, cframe)
	print(duration, text, cframe)
	if deb == false then
		deb = true
		local gui = script.Parent:WaitForChild("Dialogue")
		local frame = gui:WaitForChild("Frame")
		local dialogue = frame:WaitForChild("TextLabel")
		-- Change camera cframe if provided
		if cframe ~= nil then
			workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
			workspace.CurrentCamera.CFrame = cframe
		gui.Enabled = true
		dialogue.Text = ""
		print(duration, text, cframe)
		for i = 1, #text do
			dialogue.Text = string.sub(text, 1, i)
		gui.Enabled = false
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		deb = false

Now, this is where it gets wacky. The first line of dialogue sent to the server works fine.

 dialogue:FireServer(3, "Good morning, Bikini Bottom! Another beautiful day to work...",, 30.3439865, 241.909363, -0.630638838, -0.0015594518, -0.776074946, 0, 0.999997973, -0.00200940482, 0.776076496, -0.00126720872, -0.630637586)

But, the second line of the dialogue set makes it past the client > server. But the client handler returns all dialogue parameters as nil

 16:43:07.401  nil nil nil - Client

This was outputted using this bit of code in the handler:

print(duration, text, frame)

any help is appreciated :heavy_heart_exclamation:

If I could only quote the title I would.

So, basically, you cannot return values with a RemoteEvent. That’s the job for a RemoteFunction.

But this is just a title error. I’d suggest RemoteEvent values sending nil?

So, I looked at the syntax and the scripts and I don’t see anything wrong right away.

Except for the fact that you mention “event” and “dialogue” which confuses me a little bit, along with this:

Where it’s sending nothing.

But other than that, I don’t see any problems whatsoever. I do see the intention of the script though, to send dialog messages from the server to the client. I think it should all be done on the client, but that doesn’t matter.

I think it’s that event:FireServer() with no arguments that’s messing it up.

I assume this is caused by dialUI:GetPropertyChangedSignal("Enabled"):Wait() never firing (The dialUI is never disabled or dialUI doesn’t have a property names Enabled.) and, as Subtotal said it is returning all nil the second time on the client because of this event:FireServer() where you fire the event with no parameters. Also, this function serves no purpose as it can all be done on the client without remote events. (Unless you have other code in the OnServerEvent function that isnt shown here.)

Apart from Subtotal’s input, which DEFINITELY had something to do with the error.

Another mistake was that the script was waiting until the dialogue UI was disabled, but as soon as the event is fired, the UI is enabled. That was then considered the change in the “Enable” boolean.

The way I resolved this issue was by adding a small cooldown for the :Wait() argument:


You could technically execute this line twice, would be better than waiting arbitrarily for a single second.