-- Thanks for using my Baldi's Basics Stamina GUI! (this is better than the other ones out there)
-- You don't have to give credit since it's just a gui, but it's appreciated!


local maingui = script.Stamina:Clone()
script.Stamina:Destroy()

script.Archivable = false
script.Parent = nil -- Hides the script

game.Players.PlayerAdded:Connect(function(player)
	local function LoadGuis(player)
		game:GetService("RunService").Heartbeat:Wait() -- waits for any script that auto-clears guis to do its job
		local plrguis = player:FindFirstChild("PlayerGui")
		if (plrguis) then
			local oldgui = plrguis:FindFirstChild("Stamina")
			if (oldgui) then
				oldgui:Destroy()
			end
			local gui = maingui:Clone()
			local event = gui.Frame:WaitForChild("Speed")
			event.OnServerEvent:Connect(function(plr,sec,spd)
				if (sec == 1055299) then
					local hum = plr.Character:FindFirstChildWhichIsA("Humanoid")
					if hum ~= nil then
						hum.WalkSpeed = spd
					end
				end
			end);
			gui.Parent = plrguis
		end
	end
	LoadGuis(player)
	player.CharacterAdded:Connect(function() LoadGuis(player) end)
end)
