How do I format variables to search for something in the explorer (I don't know how to explain it)

So here is the variable, sorry if this is obvious to you:

remoteEvent = game:GetService("ReplicatedStorage").Tower(towerNumberValue)ReplicatedStorageFolder.Tower(towerNumberValue)IsSpawnedRemoteEvent

Let’s say towerNumberValue, an intValue has a value of 2. If that were the case, I would want the code to do is search for “Tower2ReplicatedStorageFolder.Tower2IsSpawnedRemoteEvent” in this module script but the problem is I have little idea of how to do that. If towerNumberValue has a value of 1 then Tower1, 3 then Tower3, etc.

1 Like
remoteEvent = game:GetService("ReplicatedStorage")["Tower"..towerNumberValue.."ReplicatedStorageFolder"]["Tower"..towerNumberValue.."IsSpawnedRemoteEvent"]
1 Like

these are 2 ways you can do it

remoteEvent = game:GetService("ReplicatedStorage")["Tower"..towerNumberValue.."ReplicatedStorageFolder"]["Tower"..towerNumberValue.."IsSpawnedRemoteEvent"]

remoteEvent = game:GetService("ReplicatedStorage"):FindFirstChild("Tower"..towerNumberValue.."ReplicatedStorageFolder"):FindFirstChild("Tower"..towerNumberValue.."IsSpawnedRemoteEvent")
1 Like

Thanks, this helped quite a bit.

Thanks, this helped with my situation.

1 Like