local objects = {} local teamcolor = BrickColor.new(script.Parent.Name)…
- User
local objects = {} local teamcolor = BrickColor.new(script.Parent.Name)
script.Parent.Essentials.Collector.Touched:Connect(function(hit) if hit:FindFirstChild("Cash") then script.Parent.Cash.Value += hit.Cash.Value game.Debris:AddItem(hit, 0) end end)
script.Parent.Essentials.Giver.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player and script.Parent.Owner.Value == player and hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Humanoid.Health > 0 then local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name) if cashmoney then cashmoney.Value += script.Parent.Cash.Value script.Parent.Cash.Value = 0 end end end end)
script.Parent:WaitForChild("Buttons") script.Parent:WaitForChild("Purchases")
for _, v in script.Parent.Buttons:GetChildren() do if v:FindFirstChild("Head") then local object = script.Parent.Purchases:FindFirstChild(v.Object.Value) if object then objects[object.Name] = object:Clone() object:Destroy() else warn("Button: " .. v.Name .. " is missing its object and has been removed.") v.Head.CanCollide = false v.Head.Transparency = 1 end
codeif v:FindFirstChild("Dependency") then v.Head.CanCollide = false v.Head.Transparency = 1 coroutine.wrap(function() while not script.Parent.PurchasedObjects:FindFirstChild(v.Dependency.Value) do task.wait(1) -- Check every second to see if the dependency was purchased end v.Head.CanCollide = true v.Head.Transparency = 0 end)() end v.Head.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player and v.Head.CanCollide and script.Parent.Owner.Value == player and hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Humanoid.Health > 0 then local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name) if cashmoney and cashmoney.Value >= v.Price.Value then cashmoney.Value -= v.Price.Value objects[v.Object.Value].Parent = script.Parent.PurchasedObjects end end end) endend
this script is very ugly and hard to read for a beginner. can you change that? maybe you can also improve this script because it's old?
- Assistant