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

LocalScript freezing after calling RemoteFunction, what is happening?

Hello. So I'm creating a GUI, which contains a LocalScript, a server Script, and a RemoteFunction in a FilteringEnabled game. For whatever reason, whenever I call InvokeServer in the LocalScript, it is just freezing - no error, no callback, if I call print after the invoke, nothing happens, but just before it works fine. Even doing extremely basic things on the server end causes it to freeze.

The hierarchy looks like this:

ScreenGui

(There's more things but they're irrelevant, I made sure that it the LS is in fact being executed)

-Frame

--LocalScript

--actuate (RemoteFunction)

--Script

--A bunch of GUI objects that aren't relevant to this

Consider the following code I was using to test it:

LocalScript

--Obviously this isn't all it does, I'm just using this to test
print(1)
script.Parent:WaitForChild("actuate"):InvokeServer()
print(2)

Server Script:

--As with the above, this is just to test
function script.Parent.actuate.OnServerInvoke(plyr)
	print("CALL")
	return true
end

1

That's all it prints, as I said there's no errors, callbacks, anything. Weirdly, it works in Solo test mode in Studio, but it fails in Local Server testing. Additionally, I've used these before and they work totally fine, but now it just seems to stop working.

1 comment

0

Very good question. Good job elaborating on what the problem is, the errors involved, as well as including the hierarchy.

1 answer

✓ Accepted answer

###Your Problem

Your code is fine. Your setup isn't.

  • Your RemoteFunction should be in ReplicatedStorage, so that both the server and the client can access it.

  • Your Script should be in ServerScriptService, so that it can run on the server.

  • Your LocalScript and Script need to reference the RemoteFunction from ReplicatedStorage

####LocalScript

local actuate = game.ReplicatedStorage.actuate;

print(1)
actuate:InvokeServer()
print(2)

####Server Script

local actuate = game.ReplicatedStorage.actuate;

function actuate.OnServerInvoke(plyr)
    print("CALL")
    return true
end

3 comments

0

But it works in other cases. Even in other frames, referencing RFs that are a child of a frame works perfectly fine.

0

Okay well I tried it anyway and it still freezes. In fact, now it freezes even in solo mode.

0

I'm afraid you're trying it wrong somehow. Your hierarchy should look similar to this: http://prntscr.com/ed5ec2

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