I made a gui for buying items and when you buy an item the weld stops working, no errors it just doesnt work anymore.
Weld: function weld()
local parts,last = {}
local function scan(parent)
for _,v in pairs(parent:GetChildren()) do
if (v:IsA("BasePart")) then
if (last) then
local w = Instance.new("Weld")
w.Name = ("%s_Weld"):format(v.Name)
w.Part0,w.Part1 = last,v
w.C0 = last.CFrame:inverse()
w.C1 = v.CFrame:inverse()
w.Parent = last
end
last = v
table.insert(parts,v)
end
scan(v)
end
end
scan(script.Parent)
for _,v in pairs(parts) do
v.Anchored = false
end
end
weld()
script:Remove()
Shop Buy: Door = script.Parent
local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
Door.Activated:Connect(function(hit)
local human = game.Players.LocalPlayer.character.Humanoid
local player = getPlayer(human)
local stats = player:findFirstChild("leaderstats")
local sp = stats:findFirstChild("Cash")
if sp == nil then return false end
if (sp.Value >=400) then
sp.Value = sp.Value - 400
print("Enough Money")
game.Lighting.AR15:clone().Parent = player.Backpack
end
end)
