this localscript was working before until I added another vehicle and I added debug and it stops after line after detecting if instance is a model it prints and doesn’t work instead lagging me
local Placeholder = script.Parent:WaitForChild("Placeholder")
local function comma_value(amount)
local formatted = amount
while true do
local formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
local function Refresh()
print("Attempting Refresh")
for _,v in script.Parent:GetChildren() do
if v:HasTag("Destroy") then
v:Destroy()
end
end
for _,v in game:WaitForChild("ReplicatedStorage"):WaitForChild("Vehicles"):WaitForChild(game.Players.LocalPlayer.Team.Name):GetChildren() do
if v:IsA("Model") then
print("What's this "..v.Name.."? OwO")
local c = script.Parent:WaitForChild("Placeholder"):Clone()
local Price = v:WaitForChild("Price").Value
local new = Instance.new("ObjectValue")
new.Name = "V"
new.Value = v
new.Parent = c:WaitForChild("TextButton"):WaitForChild("LocalScript")
c.TextButton.LocalScript.Disabled = false
c.Name = v:WaitForChild("Year").Value.." "..v.Name
--c.LayoutOrder = Price
c.Price.Text = "$"..tostring(comma_value(Price))
c.MainName.Text = v.Name
c.Year.Text = v:WaitForChild("Year").Value
c:AddTag("Destroy")
c.Parent = script.Parent
c.Visible = true
print("You've joined the party~! ^^")
task.wait(.1)
end
end
print("Refreshed :3")
end
Placeholder.Visible = false
script.Parent.Parent:GetPropertyChangedSignal("Visible"):Connect(function()
Refresh()
end)