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

Why won't this simple remote function script work?

Server Script

remoteFunction.OnServerInvoke = function(player,tweenTime1)
	tweenTime1 = 2
	
	return tweenTime1
end

I'm using remote functions to set the values for my tween since i'm doing it on the client. The values i set in the local script won't replicate to the server. so i'm having a server script return the values. Problem is, the return doesn't work, i don't see what i'm doing wrong here but it doesn't return anything, instead the variable stays at nil.

Local Script

local tweenTime1 = nil

local evaluate = remoteFunction:InvokeServer(tweenTime1)
if evaluate then
	print(tweenTime1)
end

1 answer

✓ Accepted answer

Because you are not printing the value that is being returned, instead you are printing the variable tweenTime1 that you set as nil. If you want it to print the value that the remotefunction returns then you need to print evaluate.

3 comments

0

What if i wanted to put multiple variables into the paramater for InvokeServer(), and i want to return them all at once. Is there a way to do that, cause i don't want to use multiple remote functions just to return one number with each of them.

0

You can either return a table or a tuple

0

i'l try that thanks!

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