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

Multithreading or script variations in test server problem?

I've been writing some code. I tested it in the regular play option in Studio and the code works find, but when I try it in Server Test mode the code breaks. I narrowed the problem down to a discrepancy between what the client receives and what the server sends back via return

if string.lower(string.sub(userInput,1, 5)) == "/cmds" then
			local getAdminGui = game.ReplicatedStorage:WaitForChild("GetAdmin")
			local adminContainer = getAdminGui:InvokeServer()
print(adminContainer == nil)
			if adminContainer ~= nil then
				adminContainer.Parent = game.Players.LocalPlayer.PlayerGui.ChatGui

Basically, this is from a LocalScript in the StarterGui. The problem stems from adminContainer being nil after the print statement. getAdminGUI is a RemoteFunction that calls a script from the ServerScriptService. The function returns a Frame with updated Childrens. When I use the print statement from above to check what the return is sending back, the print statement returns false (meaning that the return is not nil) but the client print statement (shown above) returns true. I am not sure why this is.

I thought it might be due to multithreading, but when I use wait() on a line right above the print statement on the above code the outcome stays the same.

Anyone know why this is?

2 comments

0

Well, seeing you used :InvokeServer(), that means you used the OnServerInvoke callback. Under any circumstances, the server should not be handling GUIs.

0

I am merely editing the GUI and giving it back to the client to display.

1 answer

✓ Accepted answer

You can't pass an object from the Sever Side to the Client Side, you could do computations and whatever edits you want to make to the gui on the serverside if it's necessary, but you would have to send them back in the form of Integers, Numbers, Vector3s, etc... Actual objects cannot be passed back.

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