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

Why does my script just stop when i invoke a remote function?

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 = script.Parent.Parent.Parent.Parent
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
RemoteDataPass.OnServerInvoke = retrievestats

--some other script

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

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.

1 answer

Log in to vote
0
Answered by
Necro_las 412 Moderation Voter
3 years ago

Print out that "script.Parent.Parent.Parent.Parent" to make sure it is getting the player. You would have no problem using game.Players.LocalPlayer to get the player in the GUI script.

Put the function retrievestats above the OnServerInvoke line. It is possible that it cant get the function that isnt already defined above.

0
the infinite script.Parent did get the player, but i wasnt aware of the other method. im using that now, thank you. as for the actual remote function, it didnt seem to change anything. Keleindor 9 — 3y
Ad

Answer this question