Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

LocalScript freezing after calling RemoteFunction, what is happening?

Asked by 7 years ago
Edited 7 years ago

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.

0
Very good question. Good job elaborating on what the problem is, the errors involved, as well as including the hierarchy. Goulstem 8144 — 7y

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago

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
0
But it works in other cases. Even in other frames, referencing RFs that are a child of a frame works perfectly fine. imaginaryuberlyuber 63 — 7y
0
Okay well I tried it anyway and it still freezes. In fact, now it freezes even in solo mode. imaginaryuberlyuber 63 — 7y
0
I'm afraid you're trying it wrong somehow. Your hierarchy should look similar to this: http://prntscr.com/ed5ec2 Goulstem 8144 — 7y
Ad

Answer this question