So, I'm trying to make a generic tycoon from my own scripts, and when I use a button script to change the furnace's parent from game.ReplicatedStorage
to game.Workspace.Tycoon
(a folder). Before the button script, it worked perfectly fine. After the button script, it just doesn't work.
Furnace Script:
game.Players.PlayerAdded:Connect(function(player) script.Parent.Touched:Connect(function(hit) if hit.Name == "Ore" then local ProcessValue = hit.OreValue local Cash = player:WaitForChild("leaderstats").Cash Cash.Value = Cash.Value + ProcessValue.Value hit:Destroy() end end) end)
Dropper Script (the script that drops the ores that the furnace is trying to process):
local OreTemplate = script.Parent.OreTemplate local Stats = { BaseValue = script.Parent.Stats.BaseValue, DropRate = script.Parent.Stats.Rate } while wait(Stats.DropRate.Value) do local Ore = OreTemplate:Clone() Ore.Parent = workspace.Ores Ore.Transparency = 0 Ore.CanCollide = true Ore.Anchored = false Ore.Name = "Ore" local OreValue = Instance.new("NumberValue",Ore) OreValue.Name = "OreValue" OreValue.Value = Stats.BaseValue.Value end
Button Script (the script that changes the furnace's parent):
game.Players.PlayerAdded:Connect(function(player) local Cost = script.Parent.Cost local Cash = player:WaitForChild("leaderstats").Cash local ObjectToAdd = script.Parent.ObjectToAdd.Value script.Parent.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum ~= nil then Cash.Value = Cash.Value - Cost.Value ObjectToAdd.Parent = workspace.Tycoon script.Parent:Destroy() end end) Cost.Changed:Connect(function() if Cost.Value >= Cash.Value then local beams = script.Parent.Beams:GetChildren() for i = 1, #beams do beams[i].Enabled = true end script.Parent.Color = Color3.new(0, 170, 0) elseif Cost.Value < Cash.Value then local beams = script.Parent.Beams:GetChildren() for i = 1, #beams do beams[i].Enabled = false end script.Parent.Color = Color3.new(255, 89, 89) end end) end)
I did it also with the dropper, and all the scripts worked 100% fine. There are no errors in the output, too.