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

[ ANSWERED ] How do I make a Remote function/event return a true/false value?

Ok, this is my first post so sorry if I make a mistake.

I'm trying to make a hotel room booking thing and I am trying to get a local script in the Gui button to fire a remote that then checks if the room is "available". Here is what I invasion it doing:

room = -- Room Value --
script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.RemoteName:FireServer(room)
	
	-- then the script waits for a return of true or false before it books the room
end)

1 answer

✓ Accepted answer

Hello. You must use a RemoteFunction. For example:

room = -- Room Value --
script.Parent.MouseButton1Click:Connect(function()
    local val = game.ReplicatedStorage.FunctionName:InvokeServer(room)

	if val == true then
		-- True code
	else
		-- False code
	end
end)

2 comments

0

ok i get i need to use a remote function now, thx. Now i need to figure out how to get a return. Any ideas where i should go to find that or...

0

to get a return, in your server script, you just have it return something at the end of your function, and in your local script, you set the variable equal to the remote function call.

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