Basically what I am trying to do is:
local path = "game.Players.LocalPlayer.Character.Humanoid"
print(path.Health)
Is there any way to do something like this?
Basically what I am trying to do is:
local path = "game.Players.LocalPlayer.Character.Humanoid"
print(path.Health)
Is there any way to do something like this?
Not that I know of. The closest you can probably get is :FindFirstChild().
My guy me neither
You cannot do this fully, however you can implement a String substitute. I haven't tested if you can use a full pathway, however, I'm sure the first reference of the pathway would have to remain legitimate if you could.
Substitution is mainly used to gain access to a descendant that has a whitespace character, making it a mandatory operation to reference it:
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character["Humanoid"]
--// or
local Character = workspace["Feahren"]
I don't think this is what he was looking for. I don't even think what he was looking for can normally be done, but with string manipulation, he can achieve something similar to it, although I don't understand why he's go through all that trouble.
These other answers are wrong, you definitely can do this with LoadStringEnabled set to true.
local path = "game.Players.LocalPlayer.Character.Humanoid"
loadstring("print(" .. path .. ".Health)")
If you use free models, and you should never use free models, putting LoadStringEnabled on is a pretty risky move. Exploiters use backdoors put into free models to get remote access to the game, and allowing loadstrings will let them run literally anything.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
You would have to parse it by . then use FindFirstChild recursively. I am unsure why you would need this.
I am 99% sure you cannot do this.
Here's a way of doing it (: https://devforum.roblox.com/t/convert-string-to-instance/385716