I’ll demonstrate for you below. Feel free to ask questions.
Script
To achieve the result you’re currently trying to obtain, you can set the string’s value to a variable.
local string_value = workspace.Part.StringValue.Value
We’re first setting a variable for the value held by the StringValue.
Then to find the Trail for your example, store it inside of ServerStorage. It doesn’t have to be inside ServerStorage, but in this example that’s where it’ll be held.
local trail = game:GetService(“ServerStorage”):FindFirstChild(string_value)
I’ll write a short conditional, that’ll let us know if we’ve found the trail or not.
if trail then
print("Trail found: ".. trail)
else
print("No trail fail!")
end
Final product
local string_value = workspace.Part.StringValue.Value
local trail = game:GetService("ServerStorage"):FindFirstChild(string_value)
if trail then
print("Trail found: ".. trail)
else
print("No trail fail!")
end
For future reference, you can use ObjectValue’s to directly reference objects.
Example
local trail = workspace.Part.ObjectValue.Value
This trail variable will let you directly store the Trail object within it.
The power of ObjectValue’s is now you can directly reference it, and do what you wish with the trail.
local trail = workspace.Part.ObjectValue.Value
trail.Parent = player.Character -- for example.
Just remember to always refer to the ObjectValue’s Value property, not just the ObjectValue instance.
I’m not sure if it’s possible to get game from a string but it is possible to get everything under it.
"Workspace.Folder.Part"
local function FindObjectInPath(Path: string): Instance
local CurrentThing = game
for _, Target in ipairs(Path:split(".")) do
CurrentThing = CurrentThing[Target]
end
return CurrentThing
end
local Object = FindObjectInPath("Workspace.Folder.Part")
print(Object) -- Part
Why would I need the trail? I mean, I’m kinda dumb at scripting… What’s even a trail? I’m trying to reach an object like if it was a normal variable, but by using what is written in the StringValue as a compass, I see no useful reason to use this “trail thing”