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

String to Path? Possible?

Asked by 4 years ago

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?

0
You would have to parse it by . then use FindFirstChild recursively. I am unsure why you would need this. User#5423 17 — 4y
0
I am 99% sure you cannot do this. killerbrenden 1537 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

Not that I know of. The closest you can probably get is :FindFirstChild().

1
My guy me neither Ziffixture 6913 — 4y
Ad
Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago

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"]
1
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. GeneratedScript 740 — 4y
Log in to vote
0
Answered by 4 years ago

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)")
1
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. Andy_Wirus 72 — 4y

Answer this question