Hi! In my tycoon game I’m trying to make buttons to buy droppers and stuff but its not working.
Idk what the problem is exactly but when I join the game the dropper is just deleted out of existence
and when I touch the button it disappears and nothing happens.
I haven’t found a solution to the problem online and it’s really complicated stuff and all the tutorials I watched just tell me to copy them without explaining anything so I don’t understand most of it.
I thought maybe its just a problem with the dropper not the button so I tried changing the item value on the button to some part and same problem.
Here is a video of what happens:
robloxapp-20210903-2309360.wmv (966.3 KB)
Please help, this is my code:
for i, v in pairs(buttons:GetChildren()) do
local NewItem = purchaced:FindFirstChild(v.Item.Value)
if NewItem ~= nil then
items[NewItem.Name] = NewItem:Clone()
NewItem.Parent = game.ServerStorage
else
v.ButtonPart.Transparency = 1
v.buttonPart.CanCollide = false
end
if v:FindFirstChild("Dependency") then
coroutine.resume(coroutine.create(function()
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
if purchaced:WaitForChild(v.Dependency.Value, 100000) then
v.ButtonPart.Transparency = 0
v.ButtonPart.CanCollide = true
end
end))
end
v.ButtonPart.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if values.OwnerValue.Value == Player then
if v.ButtonPart.CanCollide == true and v.ButtonPart.Transparency == 0 then
NewItem.Parent = purchaced
if Player:WaitForChild("leaderstats").Cash.Value >= v.Price.Value then
Player.leaderstats.Cash.Value -= v.Price.Value
items[v.Item.Value].Parent = purchaced
v:Destroy()
end
end
end
end
end)
end