So this is my first time im trying to create any game and code it by myself. My regeneration script just break buttons everytime after first player and i dont know whats the reason and how it happens. Explain in idiot language, please. Thank you for help!
-- regeneration script
local Original = script.Parent:FindFirstChild("Tycoon")
function reset()
if Original then
local backup = Original:clone()
Original:destroy()
wait(1)
backup.Parent = script.Parent
end
end
local Players = game:GetService("Players")
Players.PlayerRemoving:connect(reset)
-- function for buttons, maybe this could give you a clue of whats wrong
for i,v in pairs(Buttons:GetChildren()) do
local Object = Items:FindFirstChild(v.Object.Value)
if Object then
local TestLOL = Object:Clone()
Object:Destroy()
if v:FindFirstChild("Dependency") then
v.Button.CanTouch = false
v.Button.Transparency = 1
v.Button.CanCollide = false
v.Button.SurfaceGui.Enabled = false
coroutine.wrap(function()
if Items:WaitForChild(v.Dependency.Value) then
v.Button.CanTouch = true
v.Button.Transparency = 0
v.Button.CanCollide = true
v.Button.SurfaceGui.Enabled = true
end
end)()
end
v.Button.Touched:Connect(debounce(function(touch)
if Credits.Value >= v.Price.Value and CheckOwner(touch) then
Credits.Value -= v.Price.Value
TestLOL.Parent = Items
v:Destroy()
end
end))
end
end

5 comments
Regen script is in one model with tycoon, which in folder and has main script inside, so shouldnt it run again? or maybe it has to run after regen script at the start of the game?
or what if i keep raw version of the tycoon in server storage with turned off main script, so regen loads it fully raw and launches main script after it fully loads?
yes you could to that
keep the raw in the server storage that should work
yeah, its working, thank you for the answer!