Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is one of the arguments becoming nil?

I am trying to send a string through a remote event.

Server side:

game.ReplicatedStorage.RadioSend.OnServerEvent:Connect(function(player, t) --t is string
	local testSend = tostring(t)
	print(testSend)
	local username = player.Name
	wait(0.5)
	game.ReplicatedStorage.RadioRecieve:FireAllClients(testSend)
end)

Client side:

test.FocusLost:Connect(onFocusLost)

game.ReplicatedStorage.RadioRecieve.OnClientEvent:Connect(function(player, st)
	test.Text = (st) --Error appears on this line saying that it is a nil value
end)

Sending to the server works fine.

1 answer

Remove the 'player' argument from function() on line 3 of the client side, when you were firing on the server you only passed 1 parameter which is testSend. You didint pass anymore parameters then that so on the client side (player) has the value of (testSend) and (st) is nil

Fixed clientside code:


test.FocusLost:Connect(onFocusLost)

game.ReplicatedStorage.RadioRecieve.OnClientEvent:Connect(function(st)
    test.Text = (st) --now st will be valid because before player was taking the value of st
end)

2 comments

0

So I did that, and I am no longer getting the error but test.Text isn't changing.

0

try printing st before setting the text, and is there any reason your using ()?

This discussion is preserved as it was. New answers, comments, and votes are closed.