This is a part 2 version of the other post, but this one is more questionable. So I don’t get it why this script doesn’t work. I want the script to give a billboard to every object that has a descendants EVERYTIME. I added the while true do cause everytime when something gets inserted in the workspace it gets a marker. Let me show you:
local billboard = script.ArrowGui
while true do
wait(1)
for _, part in pairs(workspace:GetDescendants()) do
if part:FindFirstChild("Hitbox") then
local parted = part:FindFirstChild("Hitbox")
if parted.Parent:FindFirstChild("Touch") then
if not parted.Parent.Light:FindFirstChild(billboard.Name) then
local clonedbillboard = billboard:Clone()
clonedbillboard.Parent = parted.Parent:FindFirstChild("Light")
wait(0.1)
clonedbillboard.ImageLabel.ImageColor3 = (parted.Parent:FindFirstChild("Light").Color)
parted.Parent:FindFirstChild("Touch").Changed:Connect(function()
if (parted.Parent.Touch.Value) then
clonedbillboard:Destroy()
end
end)
parted.Parent:FindFirstChild("Available").Changed:Connect(function()
if parted.Parent.Available.Value == true then
wait(0.1)
clonedbillboard.ImageLabel.ImageColor3 = (parted.Parent:FindFirstChild("Light").Color)
end
end)
elseif parted.Parent.Light:FindFirstChild(billboard.Name) then
print("Already a marker.")
end
end
end
end
end
As I said earlier, there is nothing that got printed or no errors. Any ideas?
Are you trying to clone a billboardGui to every part that is named ‘HitBox’? How about change it’s adornee instead. I think I had a similar topic to this
if while true do just doesn’t then would be?
try also avoid wait when the loop has started.
local billboard = script.ArrowGui
game:GetService('RunService').RenderStepped:Connect(function()
for _, part in pairs(workspace:GetDescendants()) do
if part:FindFirstChild("Hitbox") then
local parted = part:FindFirstChild("Hitbox")
if parted.Parent:FindFirstChild("Touch") then
if not parted.Parent.Light:FindFirstChild(billboard.Name) then
local clonedbillboard = billboard:Clone()
clonedbillboard.Parent = parted.Parent:FindFirstChild("Light")
wait(0.1)
clonedbillboard.ImageLabel.ImageColor3 = (parted.Parent:FindFirstChild("Light").Color)
parted.Parent:FindFirstChild("Touch").Changed:Connect(function()
if (parted.Parent.Touch.Value) then
clonedbillboard:Destroy()
end
end)
parted.Parent:FindFirstChild("Available").Changed:Connect(function()
if parted.Parent.Available.Value == true then
wait(0.1)
clonedbillboard.ImageLabel.ImageColor3 = (parted.Parent:FindFirstChild("Light").Color)
end
end)
elseif parted.Parent.Light:FindFirstChild(billboard.Name) then
print("Already a marker.")
end
end
end
end)
end
end