Phase = 1
for i, v in pairs (script.Parent:GetChildren()) do
if v.Name == Phase then
v.Visible = true
end
end
If I replace the "If name == phase then" to if name == "1" then" it works. It just won't work with variables. Anyone know why?
Phase = 1
for i, v in pairs (script.Parent:GetChildren()) do
if v.Name == Phase then
v.Visible = true
end
end
If I replace the "If name == phase then" to if name == "1" then" it works. It just won't work with variables. Anyone know why?
You're trying to compare a string and a int value together. The reason why
Name == "1" works is because of this. "1" is the string. You'll need to change
the value of Phase to a string or use tostring() function to convert.
local Phase = "1" -- Either do this or use tostring()
for i, v in pairs (script.Parent:GetChildren()) do
--The property .Name gives you a string
if v.Name == Phase then
v.Visible = true
end
end
The word Phase needs to be a string like this
if v.Name == "Phase" then --all ways put those quotation marks around
the word a string
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Thanks!