--// bolekinds


script.Parent.Text = "Hunger:"..game.ServerStorage.ServerData.Hunger.Value
local sleeping = false
local debris = game:GetService("Debris")

game.ServerStorage.ServerData.Hunger.Changed:Connect(function()
	if game.ServerStorage.ServerData.Hunger.Value <= 40 then
		script.Parent.TextColor3 = Color3.fromRGB(255,0,0)
	else
		script.Parent.TextColor3 = Color3.fromRGB(255,255,255)
	end
	if game.ServerStorage.ServerData.Hunger.Value < 1 then
		workspace["Floppa NPC"]["Floppa cube"].Death:Play()
		for i = 25,0,-1 do
			local explosion = Instance.new("Explosion")
			explosion.Position = workspace["Floppa NPC"]["Floppa cube"].Position
			explosion.BlastRadius = 100
			explosion.BlastPressure = 60
			explosion.Parent = workspace
		end
		for i, v in ipairs(game.Players:GetPlayers()) do
			v:Kick("your floppa died")
		end
	end
	script.Parent.Text = "Hunger:"..game.ServerStorage.ServerData.Hunger.Value
end)

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if game.ServerStorage.ServerData.CatBed.Value == true then
		if game.Lighting.ClockTime == 3 then
			if workspace["Floppa NPC"].GoingTo.Value ~= nil then
				repeat wait() until workspace["Floppa NPC"].GoingTo.Reached.Value == true
			end
			workspace["Floppa NPC"].GoingTo.Value = workspace["Cat Bed"].Primary
			repeat wait() until workspace["Floppa NPC"].GoingTo.Reached.Value == true
			workspace["Floppa NPC"].Humanoid.WalkSpeed = 0
			workspace["Floppa NPC"]["Floppa cube"].zzz:Play()
			sleeping = true
		end
		if game.Lighting.ClockTime == 7 then
			sleeping = false
			workspace["Floppa NPC"].Humanoid.WalkSpeed = 9
			workspace["Floppa NPC"]["Floppa cube"].zzz:Stop()
			local ccc = game.ServerStorage["Money Bag2"]:Clone()
			ccc.CFrame = workspace["Floppa NPC"]["Floppa cube"].CFrame
			for i, v in ipairs(workspace["Floppa NPC"]:GetChildren()) do 
				if v:IsA("BasePart") then
					local NoCollision = Instance.new("NoCollisionConstraint")
					NoCollision.Part0 = v
					NoCollision.Part1 = ccc
					NoCollision.Parent = ccc
				end
			end
			ccc.Parent = workspace
			debris:AddItem(ccc, 30)
		end
	end
end)

task.spawn(function()
	while task.wait(0.5) do
		if game.ServerStorage.ServerData.Hunger.Value <= 40 then
			if workspace["Floppa NPC"].GoingTo.Value ~= nil then
				repeat wait() until workspace["Floppa NPC"].GoingTo.Reached.Value == true
			end
			workspace["Floppa NPC"].GoingTo.Value = workspace.foodplace
		end
	end
end)

workspace["Floppa NPC"].GoingTo.Changed:Connect(function()
	workspace["Floppa NPC"].GoingTo.Reached.Value = false
	local con
	con = workspace["Floppa NPC"].GoingTo.Value.Touched:Connect(function()
		workspace["Floppa NPC"].GoingTo.Reached.Value = true
		con:Disconnect()
	end)
	repeat wait() workspace['Floppa NPC'].Humanoid:MoveTo(workspace["Floppa NPC"].GoingTo.Value.Position) until workspace["Floppa NPC"].GoingTo.Reached.Value == true
end)

while task.wait(1.25) do
	if sleeping == false then
		game.ServerStorage.ServerData.Hunger.Value -= 1
	end
end
