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

My remote function stops my script. why?

Asked by 3 years ago

im trying to have a localscript attached to a UI thats trying to run a function to grab some data from a function, and it works perfectly - up until it actually invokes the server. both scripts seem to just stop, nothing having actually happened. here is the script:

the local script in the GUI:

local player = game.Players.LocalPlayer
local RemoteDataPass = game:GetService("ReplicatedFirst"):WaitForChild("RemoteDataPass")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local requestedstats = {"Str","End","Agi","Fin","Int","Will"}
local SignalPart = ReplicatedStorage.SignalParts:WaitForChild(player.Name.."'s SignalPart")
local requiredstats = {
    Str = 0,
    End = 0,
    Agi = 0,
    Fin = 0,
    Int = 0,
    Will = 0
}
print ("everything else finished")
requiredstats = RemoteDataPass:InvokeServer(requestedstats)
print ("the script is done")

and the server script being invoked (With irrelevant script omitted)

--some variables

function retrievestats (player,requestedstats)
print ("Script Invoked")
    if player == localplayer then
        print (localplayer.."'s Handler responding to request.")
        for i = 1, #requestedstats do
            local requestedstat = requestedstats[i]
            ShuffleDictionary[requestedstat] =  StatsDictionary[requestedstat]
        end
        return ShuffleDictionary
    elseif player ~= localplayer then
        print (localplayer.."'s Handler rejected request")
    end
end
RemoteDataPass.OnServerInvoke = retrievestats

--other script

again, it just seems to brick itself. the print just before the invocation fires, then both scripts go dead. it never even invokes the function or even errors. just stops.

i feel like i run into these inexplicable errors every time i try to write some script. anytime i try to outhink whatever engine bug or untraceable script error i just run into three more. it is extremely discouraging. any and all advice would be greatly appreciated.

0
is RemoteDataPass a remote function that you created via a script or is it a pre-existing remote function that you placed in manually? SteamG00B 1633 — 3y
0
its placed in by me and exists when the game starts, if you are referring to the object itself. Keleindor 9 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

There's only one thing I can think of that's causing this, and it very well may not be it. I noticed you used ReplicatedFirst as your container for your remote function, try placing it inside replicated storage (then replace the code to point to its new location) and try again. Usually replicated first is used for things like a loading screen and is the only oddity I really noticed.

If I recall correctly, ReplicatedFirst will only replicate to the client and never the server. Also, don't get down about working through all the bugs. Like others have said, it's inevitable ... take a look at my bio for proof (I haven't changed it in a while).

0
oh my god i cannot believe it. this was actually it. thank you so much! idk what i wouldve done without your sharp eye lel. looks like i need to read up on the top level services. thank you again so much! Keleindor 9 — 3y
0
No problem at all, glad it worked out for ya! SteelMettle1 394 — 3y
Ad
Log in to vote
0
Answered by
megukoo 877 Moderation Voter
3 years ago

You may want to check on your :WaitForChild()s. Those will infinitely yield the script until the part they are looking for exists, which would explain why you get no output. Wait 10 seconds after running your script, and see if there's any Infinite yield warnings.

And also, don't be discouraged when running into bugs! We all do at some point, and they're inevitable to come across.

0
The wait for child is not the problem, he said it didn't error, which would mean that it did find the remote function and it did fire it to the server. SteamG00B 1633 — 3y
0
i dont get any infinite yield warnings, so that definetly isnt the problem. in any case, they fuctions both resolve their WaitForChild calls when the remote function isnt in them. thank you for the answer though. Keleindor 9 — 3y

Answer this question