i made tycoon script, when you touch button it will buy you item (like dropper) and parent it to you Bought items folder which is located in your tycoon.
if i didnt buy item its not visible but i cant buy it.when i hit button nothing happs
no errors in output
here is script:
thank you for any help
—Varibles—
print(“Touched1”)
local TycoonModel = script.Parent.Parent
local Items = {}
local BoughtItems = TycoonModel:FindFirstChild(“BoughtItems”)
local Values = TycoonModel:FindFirstChild(“Values”)
local MainItems = TycoonModel:FindFirstChild(“MainItems”)
local Scripts = TycoonModel:FindFirstChild(“Scripts”)
local Buttons = TycoonModel:WaitForChild(“Buttons”)
MainItems.OwnerDoor.MainPart.Touched:Connect(function(hit)
if hit.Parent.Parent:FindFirstChild(“Humanoid”) and Values.Owner.Value == nil then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
Values.Owner.Value = Player
MainItems.OwnerDoor.MainPart.SurfaceGui.TextLabel.Text = Player.Name…" 's Farm"
end
end)
—Buy Functions—
for i,v in pairs(Buttons:GetChildren()) do
local NewItem = BoughtItems:FindFirstChild(v.Item.Value)
if NewItem ~= nil then
Items[NewItem.Name] = NewItem:Clone()
NewItem:Destroy()
else
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
if v:FindFirstChild("Dependency") then
coroutine.resume(coroutine.create(function()
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
if BoughtItems:WaitForChild(v.Dependency.Value,100000) then
v.ButtonPart.Transparency = 0
v.ButtonPart.CanCollide = true
end
end))
end
v.ButtonPart.Touched:Connect(function(hit)
print("Touched") ------------------------------------------------doesnt print
here is issue
if hit.Parent.Parent:FindFirstChild(“Humanoid”) then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
if Values.Owner.Value == Player then
if v.ButtonPart.CanCollide == true and v.ButtonPart.Transparency == 1 then
if Player:WaitForChild("leaderstats").Money.Value >= v.Price.Value then
Player.leaderstats.Money.Value -= v.Price.Value
Items[v.Item.Value].Parent = BoughtItems
v:Destroy()
end
end
end
end
end)
end
end