VHS tape player not working please help!

I’m trying to make this VHS TAPE player, but the code appears to not be working in my favor could someone help.

The issue could be with how I wrote the code, but I really don’t know.

I’ve tried changing some parts of the code and yet it won’t work.

local model = script.Parent
local Clicker = model.Clicker
local Play = model.Play
local Stop = model.Stop

local folder = model.Parent
local TapesFound = folder.CollectedTapes

local Activated = false

local Sounds = {
click = Play:WaitForChild(“Sound”, 5),
BackInTime = Clicker:WaitForChild(“BackInTime”, 5),

}

local ClickDetectors = {
PlayerClicker = Clicker:WaitForChild(“ClickDetector”, 5),
PlayCD = Play:WaitForChild(“ClickPlay”, 5),
StopCD = stop:WaitForChild(“ClickStop”, 5),

}

function FailedPlayer(player)
local plrgui = player:FindFirstChildOfClass(“PlayerGui”)
if plrgui then
local Message = Instance.new(“Message”)
Message.Text = “Find the tapes first.”
Message.Parent = plrgui
task.wait(5)
Message:Destroy()
end
end

function play()
if Activated then
Sounds.BackInTime:Resume()
end
end

function stop()
if Activated then
Sounds.BackInTime:Pause()
end
end

ClickDetectors.PlayerClicker.MouseClick:Connect(function(player)
if TapesFound.Value < 4 then
FailedPlayer(player)
elseif TapesFound.Value == 4 or TapesFound.Value > 4 then
Activated = true
Sounds.click:Play()
ClickDetectors.PlayCD.MaxActivationDistance = 15
ClickDetectors.StopCD.MaxActivationDistance = 15
ClickDetectors.PlayerClicker.MaxActivationDistance = 0
end
end)

ClickDetectors.PlayCD.MouseClick:Connect(play)
ClickDetectors.StopCD.MouseClick:Connect(stop)

Whats the intended result and what’s the produced result?

Please put 3 backticks (```) before and after your script. It’ll format the code so it looks as it would appear in Studio.

You know what “appears to not be working” means, but you need to describe exactly what you expect to happen and what actually happens.
For example: Player presses Play Part and the Sound starts, but doesn’t stop when you click Stop.

Troubleshooting code can be done by using print statements to display variables before each if check. This is just one place you can put a print:

ClickDetectors.PlayerClicker.MouseClick:Connect(function(player)
    print("TapesFound.Value = ", TapesFound.Value)  -- tells you what the value actually is so you can see if your code is breaking at this point
    if TapesFound.Value < 4 then
        FailedPlayer(player)
    elseif TapesFound.Value >= 4 then  --I changed this line to clean it up

After troubleshooting the code, I found the error that had to do with WaitForChild and with one of the functions. I had successfully fixed the code thanks to Scottifly’s help I found these errors, thanks bro!

local model = script.Parent
local Clicker = model.Clicker
local Play = model.Play
local Stop = model.Stop

local folder = model.Parent
local TapesFound = folder.CollectedTapes

local Activated = false

local Sounds = {
	click = Play:FindFirstChild("Sound", 5),
	BackInTime = Clicker:FindFirstChild("BackInTime", 5),
	
}

local ClickDetectors = {
	PlayerClicker = Clicker:FindFirstChild("ClickDetector", 5),
	PlayCD = Play:FindFirstChild("ClickPlay", 5),
	StopCD = Stop:FindFirstChild("ClickStop", 5)
	
}

function play()
	if Activated then
		Sounds.BackInTime:Resume()
	end
end

function stop()
	if Activated then
		Sounds.BackInTime:Pause()
	end
end


ClickDetectors.PlayerClicker.MouseClick:Connect(function(player)
	print("TapesFound.Value = ", TapesFound.Value)
	if TapesFound.Value < 4 then
		local plrgui = player:FindFirstChildOfClass("PlayerGui")
		if plrgui then
			local Message = Instance.new("Message")
			Message.Text = "Find the tapes first."
			Message.Parent = plrgui
			task.wait(5)
			Message:Destroy()
		end
	elseif TapesFound.Value >= 4 then
		Activated = true
		Sounds.click:Play()
		ClickDetectors.PlayCD.MaxActivationDistance = 15
		ClickDetectors.StopCD.MaxActivationDistance = 15
		ClickDetectors.PlayerClicker.MaxActivationDistance = 0
	end
end)

ClickDetectors.PlayCD.MouseClick:Connect(play)
ClickDetectors.StopCD.MouseClick:Connect(stop)