Nah it’s fine, I didn’t know ya were away I was just betting on your activity time tbh. I didn’t use any outside code other than the examples given, and none of them worked.
The example I gave in my post seems to work fine on my machine with the following place file.
Ambassador Example.rbxl (19.8 KB)
What Roblox Studio version are you using? I’m using 0.369.1.273919 (32bit) on Windows 10, and it works exactly as expected.
Same. Not sure why it’s breaking.
Based on that error message, it seems that Ambassador thinks the localscript is running on the server. Have you by any chance turned off accurate play solo? Currently, Ambassador doesn’t support inaccurate play solo, but it might in the future if there is enough demand for it. That still doesn’t explain the other issue that was happening online, though.
I have it turned off since I was testing something, but I’ll try with it on
Seems to be working so far, thanks!
Couldn’t you just check to see if script:IsA('LocalScript')
? That is, unless it’s a ModuleScript being required by a LocalScript, in which case I don’t think there’s any way to detect it since both RunService:IsClient
and RunService:IsServer
would return true
…
The only way to truly emulate proper inaccurate PlaySolo behavior (why would you?) is to use RemoteEvents to tell the client whether they are the client or server.
What about this?
--we're in a new thread that wraps the invocation
--no new invocation threads should be made while it doesn't finish
local current = coroutine.running()
delay(60, function() --60 seconds timeout
if current then
coroutine.resume(current)
end
end)
local response = {RemoteFunction:InvokeClient(...)}
current = nil
return unpack(response)
It should keep your threads tidy, but I’m not sure about the ones roblox manages, If it resumes again it could error, does that still consume memory?
No, that’s not what I mean. Ambassador would work on inaccurate Play Solo if it was able to detect whether it was running locally (required by / running on a LocalScript) or not (by / on a script). I’m not trying to emulate anything.
How do you detect whether the modulescript you are running a function from is running in a modulescript which was required by a modulescript which was required by a modulescript which was required by a localscript? A modulescript can run a function from another modulescript, so how do you do it? You don’t. It can’t be done.
Which is why I said in my post that
Ambassador is not being updated or maintained by the original creator of the module. It’s strongly recommended to don’t use Ambassador for production use, as it’s extremely unstable.
Is it possible to send data and receive data for the same request?
To be more specific, I would like to redeem codes:
On button click (LocalScript):
Send “redeemCode” with string containing the code to the server.
Receive data from the server and show notification.
Server:
Await for the function “redeemCode” to invoke.
Check if the code is in the list of codes.
If it is, give the award and return “Code redeemed.”.
If it isn’t, return “Code invalid.”.
I’ve tried some things out, but that’ll kick the player almost immediately with “Timeout”.