How To Make This Script Shorter(For Replicated Storage)

Hello there fellow developers,

I’am making a table(maybe more like a dictionary) that have 200 thing’s in it, but it will be a long script. I want to make it shorter so I don’t have to make it repeatly. If you still want to see what I script, here it is(It’s not 200).

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FakeRemoteEvents = {ReplicatedStorage["1"], ReplicatedStorage["2"], ReplicatedStorage["3"], ReplicatedStorage["4"], ReplicatedStorage["5"], ReplicatedStorage["6"], ReplicatedStorage["7"], ReplicatedStorage["8"], ReplicatedStorage["9"], ReplicatedStorage["10"], ReplicatedStorage["11"], ReplicatedStorage["12"], ReplicatedStorage["13"], ReplicatedStorage["14"], ReplicatedStorage["15"], ReplicatedStorage["16"], ReplicatedStorage["17"], ReplicatedStorage["18"], ReplicatedStorage["19"], ReplicatedStorage["20"], ReplicatedStorage["21"], ReplicatedStorage["22"], ReplicatedStorage["23"], ReplicatedStorage["24"], ReplicatedStorage["25"], ReplicatedStorage["26"], ReplicatedStorage["27"], ReplicatedStorage["28"], ReplicatedStorage["29"], ReplicatedStorage["30"], ReplicatedStorage["31"], ReplicatedStorage["32"], ReplicatedStorage["33"], ReplicatedStorage["34"], ReplicatedStorage["35"], ReplicatedStorage["36"], ReplicatedStorage["37"], ReplicatedStorage["38"], ReplicatedStorage["39"], ReplicatedStorage["40"], ReplicatedStorage["41"], ReplicatedStorage["42"], ReplicatedStorage["43"], ReplicatedStorage["44"], ReplicatedStorage["45"], ReplicatedStorage["46"], ReplicatedStorage["47"], ReplicatedStorage["48"], ReplicatedStorage["49"], ReplicatedStorage["50"], ReplicatedStorage["51"], ReplicatedStorage["52"], ReplicatedStorage["53"], ReplicatedStorage["54"], ReplicatedStorage["55"], ReplicatedStorage["56"], ReplicatedStorage["57"], ReplicatedStorage["58"], ReplicatedStorage["59"], ReplicatedStorage["60"]

You can see that it’s very long even though it’s not even close to 1000. If you have any idea how to make it shorter. Please tell me in the comment. Thank you.

You can do something like this, game.ReplicatedStorage:GetChildren() it returns a table.

I know that, but there are some thing that I don’t want it in the table. I don’t want it to get everything.

shorten the variable names too
Players = Plrs
LocalPlayer = LPlrs
ReplicatedStorage = RS
FakeRemoteEvents = FRE you do you but this is my sugestion

Example, if you only want remote events in that table then, do this local FakeRemotEvents = {} for i, v in pairs(game.ReplicatedStorage:GetChildren()) do if v:IsA("RemoteEvent") then table.insert(FakeRemoteEvents, v) end end

An alternative is to just pop your remotes into a folder hehe

2 Likes

Hm…, that can work, but all of them is remote event.

then what are you waiting for? do it!

I can’t because it’s a name that I don’t want it to be there.

It’s not a name, you can see I’ve done table.insert(FakeRemoteEvents, v) If I did v, then it means the table will look like this, {game.ReplicatedStorage.RemoteEvent} -- whatever your remote events are I inserted the remote event itself, not it’s name.

I don’t understand what are you saying.

I looped through everything in replicatedstorage and checked if it’s a remote event if it is then I will insert it to the table, not its name so it will look like this {game.ReplicatedStorage.RemoteEvent}

You can have a folder of the certain remote event, and :GetChildren() it. That would remove others that you dont need

1 Like

@lemolama_Pro is also correct you can use their idea

It’s not a name. It gets the “ClassName” which is like the property of an object.

v:IsA("RemoteEvent") -- Checks to see if the class you iterating over is a "RemoteEvent"
v:IsA("Part') -- Doesn't check it's name, rather it's class

I could use this, but I want to make an anti cheat so I can’t use that.

But I thought it’s a dictionary? What’s the point of hacking a dictionary game lol

:sob: :joy: Dictionaries

Definitely bookmarking this :sweat_smile:

It depends on what the dictionary thing is, and what it will achieve.

Lol, I thought it was a legit dictionary :rofl:

1 Like