Yes. The return statement does not have to return anything, it just needs to be present.
You guys ignored half my OP.
It worked a week ago. It does not now. It works again if I wait(1)
Maybe your code isnât as fine as you claim it is.
If it worked previously, and works now with a wait(1) before it, I think itâs pretty obvious that the problem is on ROBLOXâs end and not his.
Why would this be true? I donât think this is true. By nature of Lua, functions return nil if no explicit return statement is written.
I distinctly remember seeing it on the wiki, but it seems this is no longer the case.
@nwspacek thereâs obvious evidence that this isnât my problem. Why do you insist on the alternative? My methods worked last week but donât work this week, at least not reliably.
Thereâs evidence that it is your problem. How many people asked you why you are using remote functions instead of remote events? That should be a hint that something isnât right on your end.
There have been numerous bug reports on this forum where the problem was code. This looks like one of them.
Why does it matter what he should use, youâre tangenting.
What matters right now is what he is using, and he has a problem with it working like documented. He doesnât care about your specific preferences in coding, or which method of networking you think works better, he just wants his to work like it should be working.
I donât think ScriptOn is a new enough scripter that his issue is poor code, and choosing to design something one way instead of another isnât poor code, at very most itâs bad practice. He has a legitimate complaint and Iâd like to see people actually try to help him. From my point of view, I stand to benefit once all the stuff with Remotes gets ironed out, as my game has small issues with remotes fairly often, but never in ways I could reproduce before.
Could you post your code appertaining to this? I wouldnât mind reading over it and seeing if I can see and problems.
It is not a tangent. Since it was not obvious, I will explicitly state what I am saying: I think RemoteFunctions are causing problems and that RemoteEvents will fix it. Ergo, it does matter what he should be using.
Here is the code I use to get player response for things like round starting, modified to fit this case:
local remote = workspace.RemoteEvent
--server
local PlayersInGameAtThisMoment = game.Players:GetPlayers()
function StartGuiAndTeleportPlayers()
local ClientsNotResponded = PlayersInGameAtThisMoment
local ClientsResponded = {}
local ClientResponseConnection --defining the variable to use outside of the declaration is only necessary when disconnecting inside the connection itself, but this method is a good habit because it works for all cases.
ClientResponseConnection = remote.OnServerEvent:connect(function(client,data) --the client has pinged back
if data == "ReadyForTeleport" then --the client has said the magic word
table.insert(ClientsResponded) --keep track of who responded
for i,p in ipairs (ClientsNotResponded) do
if p == client then
table.remove(ClientsNotResponded,i) --update the list of those who did not respond
break --now that we found the culprit, we can stop searching
end
end
local torso = client.Character and client.Character:FindFirstChild("HumanoidRootPart") --make sure they have a part we can teleport, first
if torso then
TeleportPlayerToGame(torso)--beam me up, scotty!
end
end
end)
remote:FireAllClients("StartMatch") --clients can choose to ignore this at their peril
wait(5) --wait an arbitrary length of time to allow the game to move forward in a timely fashion. This assumes the GUI animation is no longer than 1 second.
ClientResponseConnection:disconnect() --we no longer wish to concern ourselves with clients phoning back
return ClientsResponded, ClientsNotResponded --this can be useful elsewhere
end
--client
remote.OnClientEvent:connect(function(data)
if data == "StartMatch" then
_G.StartMatchGui()
remote:FireServer("ReadyForTeleport")
end
end)
Please stop.
My code is my code. This problem is robloxâs problem. This isnât posted in Development Discussion so I donât understand why you have to enforce your thoughts/opinions onto me.
What may happen I think is that if the script that you implement OnClientInvoke in stops executing - e.g. is disabled, restarted or runs to the end - the function call from the server will disappear into ether.
Whatâs the behavior on the server? Any error messages?
The script is run once and I use prints to make sure it reaches the proper location. No error messages on the server. Server just moves on.
Found the issue.
If you have two localscripts both calling .OnClientInvoke then only one of them connects.
Yeah, only one script can define a callback at a given time.
We thought about having a warning in case you override, but itâs somewhat challenging to implement so that it does not misfire for UI scripts that are reloaded when player is reset.
Ah.
Rather frustrating. Well at least I got it figured out.
I thought I might be able to elaborate a little bit.
OnClientInvoke is whatâs called a âCallbackâ. Itâs kinda like a property where the value of that property needs to be a function.
By setting it twice, you set the callback to the first function and then you overwrite the callback with a new function.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.