How to reference the child using a value

Hey, I am making a script that goes something like this.

game.ReplicatedStorage.RedGuard

Is there a way that I can use a string value in place of the “RedGuard”. My idea is something like this,

value = scipt.Parent.Value
game.ReplicatedStorage.value

Does anyone know if this is possible?

1 Like

Should be as simple as

value = scipt.Parent.Value
game.ReplicatedStorage[value]
2 Likes

Capitalisation is important, so if the instance is named “Value” then you must refer to it as so, this is similar to if the instance is named “value”.

game.ReplicatedStorage.Value
script.Parent.Value

These would refer to the Value instance itself, to read from the value currently assigned to the “Value” property of the instance you would need to do.

local Value = game.ReplicatedStorage.Value.Value
local Value = script.Parent.Value.Value
1 Like