I solved this by checking (on the second function) whether the position was at a Y-Scale coordinate of 400. Thanks to all those who replied.
When I run this, saying "commands" makes the GUIs move out of their position, and saying "commands off" moves them back. If I say "commands" again, the GUIs do not move back to their position. How do I make it move back on saying "commands" again? --Edit, I need this to work only for my character, and it'd be more efficient if I could do it with the same command.
To test it: https://www.roblox.com/games/862131713/Empty-Lot
wait(3)
for i, v in pairs(game.Players:GetPlayers()) do
--if v.Character.Name == "Sabaist" then
v.Chatted:connect(function(msg)
if msg == "Commands" or "commands" then
for s, h in pairs(script.Parent:GetChildren()) do
toggle = true
if h:IsA("TextBox") and toggle == true then
local const = h.Position.Y.Offset
h:TweenPosition(UDim2.new(0, 400, 0, const), 'In', 'Bounce', 3)
toggle = true
end
end
end
end)
end
for i, v in pairs(game.Players:GetPlayers()) do
--if v.Character.Name == "Sabaist" then
v.Chatted:connect(function(msg)
if msg == "Commands Off" or "commands off" then
for s, h in pairs(script.Parent:GetChildren()) do
if h:IsA("TextBox") and toggle == true then
local const = h.Position.Y.Offset
h:TweenPosition(UDim2.new(0, -400, 0, const), 'Out', 'Bounce', 3)
toggle = true
end
end
end
end)
end

1 comment
Updated my answer including the edits from your comment