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

Help, line of code may be incorrect // I'm doing it wrong?

Asked by 8 years ago
            wait(.5)
            Instance.new("Part",game.Workspace.Fires).Name = player.Name.."'s fire"
            local Fire = game.Workspace.Fires."player.Name."'s fire"

So this script is suppose to create a brick, name the brick after the player who created it + 's fire, then make a variable named Fire of that brick. It'm not really sure how to code the 3rd line, any help??

2 answers

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago

You can use brackets to search for a child via a string;

workspace.Fires[player.Name.."'s fire"]

This works the same way as a dot, it just allows strings, numbers, etc.


It would probably be better, however, to just define the variable when you create the part, just to make extra sure you get the correct one.

local Fire = Instance.new("Part", workspace.Fires)
Fire.Name = player.Name.."'s fire"
Ad
Log in to vote
0
Answered by 8 years ago

If you predefine the object you created before, it would be easier to access it. Assuming you defined "player"

wait(0.5)
local Fire = Instance.new("Part", game.Workspace.Fires)
Fire.Name = player.Name.."'s fire"

Answer this question