Hi, so i've been trying to make a dependency system for my tycoon. I have made most of it, i have encountered a problem which is when i purchase the required item it wont change the parent of the button to a folder in workspace, which i dont know how to fix! Does anybody know a fix?
just a rblx studio screenshot https://gyazo.com/73502cb6c428ef238ec199c7da1554ec
Line 29 to 37 is dependency handling
My script
local tycoon = script.Parent
local buttons = tycoon.Buttons
local buyables = tycoon.Buyables
local bought = tycoon.Bought
local tycoonitems = game:GetService("ServerStorage").TycoonItems:FindFirstChild(tycoon.Name)
local required = tycoon.Required
local debounce = false
local door = required.Door
door["Touch To Claim"].Head.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr and tycoon.Owner.Value == required.Floor then
tycoon.Owner.Value = plr
door["Touch To Claim"].Name = plr.Name.."'s Tycoon"
end
end)
for i, v in pairs(buttons:GetChildren()) do
if v then
v.Config.Object.Value.Parent = tycoonitems
-- Dependency handling
if v.Config.Dependency.Value then
v.Parent = tycoonitems.Tycoon1Buttons
end
v.Config.Dependency.Changed:Connect(function()
if not v.Config.Dependency.Value then
v.Parent = buttons
end
end)
v.Head.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if not debounce and tycoon.Owner.Value == plr and not v.Config.Dependency.Value then
if plr.leaderstats.Cash.Value >= v.Config.Price.Value then
debounce = true
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - v.Config.Price.Value
print("I've been touched!")
print("I can be placed!")
v.Config.Object.Value.Parent = bought
v:Destroy()
wait(1)
debounce = false
end
end
end)
end
end
