Second if statement is not working!

local gui = script.Parent
local typewritermodule = require(script.Typewriter)
local container = script.Parent.Frame:WaitForChild("Container")
local object = typewritermodule.new(container)
local sleep = game.ReplicatedStorage.Remotes.DayAndNightEvents.Sleep
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local bed = game.Workspace.Bed:WaitForChild("TestBed").ClickDetector
local issafe = game.ReplicatedStorage.DayValue.IsSafe
local backtosleep = game.ReplicatedStorage.Remotes.DayAndNightEvents.GoBackToSleep
local isnight = game.ReplicatedStorage.DayValue.IsNight
local whatday = game.ReplicatedStorage.DayValue.whatday
local function guifadeinout(Gui)
	
	repeat 
		wait(0.1)
		Gui.BackgroundTransparency += 0.1
	until Gui.BackgroundTransparency == 1
end


bed.MouseClick:Connect(function()
	if tiredornot.Value == "Yes" then
        wait(0.2)
		mouse.Icon = "rbxassetid://5054846840"
		gui.Enabled = true
		wait(2)
		object:typewrite("Night "..whatday.Value)
		wait(5)
		tiredornot.Value = "No"
		container.Visible = false
		sleep:FireServer()
		guifadeinout(gui.Background)
		wait(2)
		gui.Enabled = false
		container.Visible = true
	end
	if tiredornot.Value == "Yes" and issafe.Value == true and isnight.Value == true then
		wait(0.2)
		gui.Enabled = true
		wait(2)
		object:typewrite("Day "..whatday.Value)
		wait(6)
		guifadeinout()
		container.Visible = false
		gui.Enabled = false
		container.Visible = true
		tiredornot.Value = "No"
		backtosleep:FireServer()
	end
end)
```  so basically, the game will check if the player is tired or not, if it is, then sleeping will happen, but if the player is tired and the player is safe and it's night then the player will go back to sleep for day 2
2 Likes

o basically, the game will check if the player is tired or not, if it is, then sleeping will happen, but if the player is tired and the player is safe and it’s night then the player will go back to sleep for day 2

2 Likes

Wrong category, I would recommend using a bool value for tiredornot and also using task.wait and using waitforchild for some of your variables since its a client script, I don’t see a reason for the second if statement to not be working I would recommend putting print checks everywhere to see more.

1 Like