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

How to make a remote event in replicated storage using a script?

Asked by 3 years ago
local q = Instance.new("RemoteEvent")
    q.Name = q

now i know how to make a remote even although i have no clue how to give it a destination for example make a remote event in replicated storage

pls help

2 answers

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

First of all, your remote event name has to be a string. Secondly, there's 2 options to set the parent. You can use the 2nd parameter of Instance.new() which is the parent of the script. It is deprecated however, so I do not suggest using it. Instead use q.Parent after making the Instance.

local q = Instance.new("RemoteEvent")
q.Name = "q" --It HAS to be a string
q.Parent = game.ReplicatedStorage --You're setting the parent of the remote event
0
Edit: Just made some unnecessary edits. Dovydas1118 1495 — 3y
0
@Dovydas1118 I suggest parenting it FIRST to prevent errors. Sensei_Developer 298 — 3y
0
@Dovydas1118 I suggest parenting it FIRST to prevent errors. Sensei_Developer 298 — 3y
0
@Dovydas1118 I suggest parenting it FIRST to prevent errors. Sensei_Developer 298 — 3y
View all comments (5 more)
0
@Dovydas1118 I suggest parenting it FIRST to prevent errors. Sensei_Developer 298 — 3y
0
@Dovydas1118 I suggest parenting it FIRST to prevent errors. Sensei_Developer 298 — 3y
0
ok stop spamming me Dovydas1118 1495 — 3y
0
Ohmygod I'm so sorry! I didn't mean to spam! I Accidentally clicked the "Post" button too many times! Sensei_Developer 298 — 3y
0
It's no problem. Anyways, thanks for the info. I'll make sure to parent it first. Dovydas1118 1495 — 3y
Ad
Log in to vote
1
Answered by 3 years ago

You forgot to parent the instance. You see, if an instance (any object, like RemoteEvents) has no parents, it won't appear.

I would type it like this:

local remoteEvent = Instance.new("RemoteEvent") --variable that's not a single letter to make it less confusing
remoteEvent.Parent = game.ReplicatedStorage --you ALWAYS want to parent the RemoteEvent first to prevent any errors
remoteEvent.Name = "remoteEvent name here"

Also, next time when you post, try and make it more descriptive. It was kind of hard for me to read and understand.

0
ok ill try soreno2468 31 — 3y

Answer this question