Problem with Passing Variables trough RemoteEvent

Im currently working on an adminsystem and whenever the the script runs into an error it sends a variable from a localscript to a serverscript and the serverscript then sends it into another localscript.

When the variable is sent to the serverscript its entirely fine, but when the serverscript then sends it to the other localscript it just becomes “nil” for whatever reason making it useless for me. I have no clue how it could lose its value when its transfered the second time.

Serverscript:

event.onServerEvent:connect(function(player, message)
	print(message)
	event2:FireClient(player, message)
end)

Localscript:

event.onClientEvent:connect(function(player, message)
	if debounce == true then
		debounce = false
		script.Parent.Text = message
		script.Parent.Parent.Notif:Play()
		script.Parent.Parent:TweenPosition(UDim2.new(0.867, 0,0.849, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.5)
		wait(5)
		script.Parent.Parent:TweenPosition(UDim2.new(1.867, 0,0.849, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.5)
		wait(0.6)
		debounce = true
	end
end)

and this is the error that I get: “Players.Flauschi_XD.PlayerGui.Notification.Frame.TextLabel.LocalScript:7: invalid argument #3 (string expected, got nil)”

Which refers to script.Parent.Text = message

3 Likes

Message for whatever reason is nil so could you print(message) on the client (just like you did on the server)?

2 Likes

I tried that, but nothing showed up on the console.

1 Like

As in it printed nil or it didn’t print anything at all? Make sure you’re printing the message right before you do
“script.Parent.Text = message”.

1 Like

Alright so. You might remember the problem I had yesterday. Half of the solution was to put “player” before the other variables. Here it aparently caused the problem.

I was able to fix it by just doing event.onClientEvent:connect(function(message) instead of the event.onClientEvent:connect(function(player, message) I did in the script above.

1 Like