I have no idea why this code runs 2 times. Its a local script in startergui
local player = game.Players.LocalPlayer
while true do
local energy = player:WaitForChild("Energy_Amount")
if player:WaitForChild("Energy_Maker").Changed then
print("1")
if game.ReplicatedStorage.DoNotRemove.Value == player:WaitForChild("Energy_Maker").Value then
else
print("2")
if player:WaitForChild("Energy_Maker").Value == 1 then
if energy.Value >= 3 then
else
wait(3)
print(player:WaitForChild("Energy_Amount").Value)
game.ReplicatedStorage["power sources"].oil["oil" .. tostring(player:WaitForChild("Energy_Amount").Value)].Parent = game.Workspace
game.ReplicatedStorage.DoNotRemove.Value = player:WaitForChild("Energy_Maker").Value
end
end
if player:WaitForChild("Energy_Maker").Value == 2 then
if energy.Value >= 4 then
else
wait(3)
game.ReplicatedStorage["power sources"]["bio fuel"]["biofuel" .. tostring(player:WaitForChild("Energy_Amount").Value)].Parent = game.Workspace
game.ReplicatedStorage.DoNotRemove.Value = player:WaitForChild("Energy_Maker").Value
end
end
if player:WaitForChild("Energy_Maker").Value == 3 then
if energy.Value >= 10 then
else
wait(3)
game.ReplicatedStorage["power sources"].tide["tideGen" .. tostring(player:WaitForChild("Energy_Amount").Value)].Parent = game.Workspace
game.ReplicatedStorage.DoNotRemove.Value = player:WaitForChild("Energy_Maker").Value
end
end
if player:WaitForChild("Energy_Maker").Value == 4 then
if energy.Value >= 5 then
else
wait(3)
print("3")
print(player:WaitForChild("Energy_Amount").Value .. script.Parent.Energy_Test.Value)
game.ReplicatedStorage["power sources"]["natural gas"]["Natural Gas" .. tostring(player:WaitForChild("Energy_Amount").Value)].Parent = game.Workspace
game.ReplicatedStorage.DoNotRemove.Value = player:WaitForChild("Energy_Maker").Value
end
end
if player:WaitForChild("Energy_Maker").Value == 5 then
if energy.Value >= 5 then
else
wait(3)
game.ReplicatedStorage["power sources"].GEOTHERMAL["biofuel" .. tostring(player:WaitForChild("Energy_Amount").Value)].Parent = game.Workspace
game.ReplicatedStorage.DoNotRemove.Value = player:WaitForChild("Energy_Maker").Value
end
end
if player:WaitForChild("Energy_Maker").Value == 6 then
if energy.Value >= 4 then
else
wait(3)
game.ReplicatedStorage["power sources"].hydroelectricity["hydro" .. tostring(player:WaitForChild("Energy_Amount").Value)].Parent = game.Workspace
game.ReplicatedStorage.DoNotRemove.Value = player:WaitForChild("Energy_Maker").Value
end
end
if player:WaitForChild("Energy_Maker").Value == 7 then
if energy.Value >= 12 then
else
wait(3)
game.ReplicatedStorage["power sources"].wind["windTurbine" .. tostring(player:WaitForChild("Energy_Amount").Value)].Parent = game.Workspace
game.ReplicatedStorage.DoNotRemove.Value = player:WaitForChild("Energy_Maker").Value
end
end
if player:WaitForChild("Energy_Maker").Value == 8 then
if energy.Value >= 4 then
else
wait(3)
game.ReplicatedStorage["power sources"].coal["Coal Gen" .. tostring(player:WaitForChild("Energy_Amount").Value)].Parent = game.Workspace
game.ReplicatedStorage.DoNotRemove.Value = player:WaitForChild("Energy_Maker").Value
end
end
if player:WaitForChild("Energy_Maker").Value == 9 then
if energy.Value >= 8 then
else
wait(3)
game.ReplicatedStorage["power sources"].solar["solarPannel" .. tostring(player:WaitForChild("Energy_Amount").Value)].Parent = game.Workspace
game.ReplicatedStorage.DoNotRemove.Value = player:WaitForChild("Energy_Maker").Value
end
end
if player:WaitForChild("Energy_Maker").Value == 10 then
if energy.Value >= 4 then
else
wait(3)
game.ReplicatedStorage["power sources"]["nucular power"]["nucular" .. tostring(player:WaitForChild("Energy_Amount").Value)].Parent = game.Workspace
game.ReplicatedStorage.DoNotRemove.Value = player:WaitForChild("Energy_Maker").Value
end
end
end
end
wait(1)
end

