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

Remote Functions, callback not receiving value?

so, here is the code: (note that the code is in separate scripts, its server -> local I just took them out separately)

--server
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		
					
					spawn(function()
					--note WT is declared outside the function globally at the top of the code
						for i = 0, 5 do
							wait(1)
							WT = WT + 1
						end
						
					WT = 0
					end)
					
					spawn(function()
						event:InvokeClient(player, WT)
					end)


--client

event.OnClientInvoke = function(player, WT)
	
	ACE = WT
	
end

the issue is, when I print ACE I get a nil value, and if I print WT I do too. so the number values of 5-1 are not being received by the callback function, am I using this wrongly or am I missing something?

1 answer

✓ Accepted answer

The problem is that OnClientInvoke does not have any arguments before the ones passed to it; i.e. there is no player argument:

event.OnClientInvoke = function(WT)
	ACE = WT
end

1 comment

0

oh, my mistake- thanks for the answer!

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