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

[SOLVED] How do I pass data with events?

Asked by
7z99 203 Moderation Voter
4 years ago
Edited 4 years ago

Hello!

I'm trying to pass an object from a normal script to a localscript which I wasn't able to do since I'm not sure how to get the sent object with the localscript. I looked at this developer link about remote functions and events, but it was very unclear to me, and I wasn't able to find out how.

eventName:FireAllClients(script) -- should send the script object

Now for the localscript:

eventName.OnClientEvent:Connect(functionName) -- when the event is fired, it connects to the function, but how do I receive the script object from this localscript?
0
You cannot send Object's as arguments. You can receive arguments in the form of parameters: function foo(param1, param2) Ziffixture 6913 — 4y
0
See https://developer.roblox.com/en-us/articles/Function to understand more about arguments & parameters. Ziffixture 6913 — 4y
0
I'm basically asking if the script gets stored as a variable? 7z99 203 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Hello, 7z99! The problem with passing objects with FireClient() is that they might not be rendered yet (StreamingEnabled) or that the object isn't accessable with LocalScripts. For example, you cannot fire a script through with FireClient(). You also can't fire things in ServerStorage or ServerScriptService as they are only accessible to the server. For more information go to the Server-Client Model on the Roblox Developer Hub. Make sure to accept this answer if it hepls you.

0
I know this, however it should be possible as the player would never be far enough away from the part for it to not be rendered. 7z99 203 — 4y
0
To simplify, I'm just asking if the "script" object gets stored as a variable, and if so, how do I access or modify the variable/ 7z99 203 — 4y
0
You cannot modify the script variable on the client, however, you can on the server. The player can be far enough from the part for it to not be rendered if you have Streaming Enabled on. (Property of Workspace.) youtubemasterWOW 2741 — 4y
Ad
Log in to vote
0
Answered by
7z99 203 Moderation Voter
4 years ago

I ended up solving it.

Normal Script:

eventName:FireAllClients(script)

LocalScript:

eventName.OnClientEvent:Connect(functionName)

function(argument1) -- brackets are where the arguments go
    --pretend this does stuff lol
end

Answer this question