I have this set of code here. It works all the way until this part:
for i,v in pairs(mouse.Target:GetDescendants()) do
I want to know how I can replace this with a semi-infinite loop that checks until a certain outcome is made. Heres the full code:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local mouses = { "http://www.roblox.com/asset/?id=409468479" } local rs = game:GetService("RunService") local ObjectInfo = script.Parent:WaitForChild("ObjectInfo") local TextInfo = ObjectInfo:WaitForChild("TextLabel") local debounce = true -- mouse.Icon = mouses[1] -- rs.RenderStepped:Connect(function() if debounce then if mouse.Target ~= nil then if mouse.Target:FindFirstChild("NameLabel") then debounce = false local Start = UDim2.new(0.422, 0,1, 0) local Goal = UDim2.new(0.422, 0,0.874, 0) TextInfo.Text = mouse.Target.NameLabel.Value TextInfo.Position = Start local tween = TextInfo:TweenPosition( Goal, Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, true ) wait(1) for i, v in pairs(mouse.Target:GetDescendants()) do print(v) if v.Name ~= "NameLabel" then TextInfo.Position = Goal local tween = TextInfo:TweenPosition( Start, Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, true ) wait(1) print("true") debounce = true else print("false") debounce = false end end end else TextInfo.Text = "" end end wait() end)
Hopefully you guys can help and maybe find a few other errors I might of not seen.
Try:
local success repeat for i, v in pairs(mouse.Target:GetDescendants()) do print(v) if v.Name ~= "NameLabel" then TextInfo.Position = Goal local tween = TextInfo:TweenPosition( Start, Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 1, true ) wait(1) success = true debounce = true else success = false debounce = false end wait() until success = true
Sorry for the formatting, I’m on mobile and I didn’t test it, basically we define success as a blank variable, and keep checking if the loop sets it to true. You get the idea.