I need help debugging a script that relies on a NumberValue

Main Script

Open to see
local TRUEINSANITYHITS = workspace.TRUEINSANITYHITS
local SS = game:GetService("ServerStorage")
local remoteStorage = game:GetService("ReplicatedStorage")
local remoteEvent = remoteStorage.TRUEINSANITYWINNER
local FIGHTBUTTON = SS.FightButton
local players = game:GetService("Players")
local music = workspace.Lethalovania

while true do
	if TRUEINSANITYHITS.Value <= 14 then
		task.wait(3)
		local FIGHTBUTTONCLONE = FIGHTBUTTON:Clone()
		FIGHTBUTTONCLONE.Parent = workspace
		FIGHTBUTTONCLONE.Script.Enabled = true
	elseif TRUEINSANITYHITS.Value >= 15 then
		print("Ś̵̛̱̮̄̓̌̉̌̓̆̈́̀͗̌̔̿͐͘͘̕͝Ó̸̡̡͇͓̰̤̰̼̪̞̳͎̪͛͂̆M̸̢̢̛̱̱̬͚͚̄̒́͛̐́̃̉͌̀̍͑͐͑̕̚̕͜͠Ȅ̸̢̧̧̠͓̮͍̙̜͕͉̮͎͓͈̄͐̈̍̒̐̋̅̈́͂͒̓̒͛̎͘O̷̦̘̣̺̮͚̯̰̩̬͓̥̞̮̠̮̜͒̊́̿̃̍̾̒́̐̈́͛̉̔͌̿̀͠N̷̛͎̠̮̫̯͙̲̿̄͐̿̕͝Ẹ̴̔̑́͗̒͛̎͆ ̷͚̓̀̏́̔̐́̇̋̓̎͒̄͝Ḣ̵̡͈͕̲̥̪̗̮̠̞̬̺̱̄́͊͊̿Á̸̲̞̥̗̰̣̮́͂̆̒̒͋͘ͅS̷̢̲͔͈̜̯̜͖̗̫̖̰̱̮̙̞̲̺͇̣͇̍̌̇̍̀͘͝ ̵̢̛̥̩͍͕̪̰̜̖̦̬̜̯̈́̓̇̀̈́̀̈̾̉̊̄̕̚͜͠͝͠C̸̛̜͉͖̘̖̗̬̳͂̃̅̀̑̏͂͘͜Ǫ̴̛̫̱̱̥̣̬̺̱̙͚̖͍̬̠̓͗̈́͋̍̏̽̚͝Ǹ̶̛̤̥̟̰̖̺̘̠̍͂̏̃̓̋̍̒́̎͌͘͜͝Q̵̛̟̟͖̮̺͇̒̋͋̾͆̇̂͑̏́͐̌͋̔̅̂̚Ư̸̪̣̙̙̠̝̬̩̙̳̱̊̇̔̀̔͑͐̔̃͘Ȩ̶̜̪̮̰̹̩̳̪̻̠̖̻̘̥̩̗̀͜ͅR̷̞̺̦̰̭̰̘̰͎̲̒E̴̡̨̠̱̼̺̠̼͔̬̬̣̟̬̲̍Ḑ̷̧̨̛̛̛̞̟̦̻̻͇̻̩͉̱̝̖̫̭͓̍̇͗̊̈́͂̂͆́̈͗̍̕̚̚͜ͅ ̶̢̢̧͇̲̰͓͙͉̜̦͍̘͖̭͉̽̈́̃̂̀͊̐̅̂̒̈͒͐̈̒̎̓̀̈ͅT̷̨̧̜͕̜̝̦̹͔̰̺̎̅̏̏̋̃͘̚͜͜͝H̷̢̢̭̝̗̱̫̪͕̰͓̭͚͙̣̤̖̻̞̤̟̋́̑́̏̈́͘ͅȨ̶̟̜̞͍̬͕̗͇̪͇̣̳͎̓̈́̽̄̀̏̌̃͗̏̓̽̑͒̄͒̈́͋̉̃͝ͅ ̴͖̪͓̥͚̒̽̅͗T̵͙͂͊̈̋̓͂̒̆̋̇͛̀͂̅̚͘͝͠R̶͓̟̔̒̑̆͋͂͆̈́̈Ư̸̧̫̘͙̜͓̟̭̞̝̲̫̼̘̝̖̰̒̎̒̊͐̿̎̇͌͐̽͒͆͊͗͒̈Ȩ̵̢͈̝̭̪̩̮̰̭̟̠̯̠̰̺̫̝̺͖̰̌̈́͌̍͌̐̇͠ͅ ̸̢̧̟̺̙̳̗̙̫̼̹̪̼̟͙̻̼͙͂̄̊̃̇́̑̽͋̐͒̕͠ͅͅB̵̛̫͉̯͕̂̃̌͗̓̄̾́͛͂̑̉͒͊̈͘̚̚͝ͅA̶̝͇̬̼̪̖͙͚͈͉̫̔̄̌͑́͌͛̊͜͜ͅṚ̴̙̝̲̗̜̞̲̲̭̟̔̂͒̑̀̊̅̅̿̚͜͝Ṟ̶͈͐̿͑̊̔̓̇̂̓̎̓̄͋̚Ḭ̸̛͎̹̞̝̀́̊̏́̎̑̎͌̄̒͜͝͝Ę̸̬̰̘̠̭̬̥̼͙͕͚̞͍̱̹̱̥͇̞̫̍̋̎̏̒̌͗͂̿̈͑͆̎̽͑̓͘͘͝Ṟ̵̢̨̟̥͙̖̒͆͂͑̐͌̓̓́̌̎͐̉̈́̔͊̕͘͝͠ͅ")
		music.Looped = false
		music:Stop()
		local sans = players:FindFirstChildOfClass("Player")
		local backpack = sans.Backpack
		if sans.TeamColor == BrickColor.new("Navy blue") then
			local character = sans.Character
			if character:FindFirstChildWhichIsA("Tool") then -- IF PLAYER IS ABUSING A BUG, DESTROY CURRENT HOTBAR REGARDLESS
				character:FindFirstChildWhichIsA("Tool"):Destroy()
			end
			for _, backpackItems in pairs (sans.Backpack:GetChildren()) do
				backpackItems:Destroy()
			end
			remoteEvent:FireAllClients()
			break
		else
			print("What else is there?")
		end
	end
	task.wait(0.01)
end
2nd Script (FightButton)
local TRUEINSANITYHITS = workspace.TRUEINSANITYHITS
local parent = script.Parent
local debounce = false
local RNG = math.random(1,2)
local sound = parent["UnderTale - Barrier Breaking Sound Effect"]
local count = 15

while true do
	--VARS
	local teams = game:GetService("Teams")
	local team = teams.Chara
	parent.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") and debounce == false and game.Players:GetPlayerFromCharacter(hit.Parent).Team == team then
			debounce = true
			TRUEINSANITYHITS.Value += 1
			print("HIT")
			sound:Play()
			task.wait(2)
			debounce = false
			parent:Destroy()
		end
	end)
---The part after this completely works and does not need any changes. The part above is more important than the ones below.---
	if RNG == 1 then
		parent.Position = parent.Position + Vector3.new(math.random(-225,225),0,-150)
		while count <= 999999999999 do
			repeat
				for i = 1,15 do
					parent.Position = parent.Position + Vector3.new(0,1,2.5)
					task.wait(0.01)
				end

				for i = 1,15 do
					parent.Position = parent.Position + Vector3.new(0,-1,2.5)
					task.wait(0.01)
				end
				count -= 1
			until count == 0 
			break
		end
		task.wait(0.01)
		parent:Destroy()
		task.wait(329848234823483428342898934289234)
	end
	if RNG == 2 then
		parent.Position = parent.Position + Vector3.new(-150,0,math.random(-225,225))
		while count <= 999999999999 do
			repeat
				for i = 1,15 do
					parent.Position = parent.Position + Vector3.new(2.5,1,0)
					task.wait(0.01)
				end

				for i = 1,15 do
					parent.Position = parent.Position + Vector3.new(2.5,-1,0)
					task.wait(0.01)
				end
				count -= 1
			until count == 0 
			break
		end
		task.wait(0.01)
		parent:Destroy()
		task.wait(329848234823483428342898934289234)
	end
	task.wait(0.01)
end

Important stuff:
The value used is a NumberValue.
The remoteEvent isn’t used yet.
The print does not show up.

Ignore the print’s message, it’s meant to be there for visual.

For context, this is a ServerScript. The player has to touch a fight button in order to increase a counter just so they can defeat a certain character in the game (the value increases by 1). After a player touches a Fight Button 15 times, the game will destroy all the Sans tools, then activate dialogue and later kick all the players from the server. While the scripts might seem fine, they aren’t.

What I mean is that I don’t see the print. local TRUEINSANITYHITS = workspace.TRUEINSANITYHITS even after reaching a number value of 15 or higher does not appear to fire off the 2nd event for the main script, that being elseif TRUEINSANITYHITS.Value >= 15 then.

Now, for technical stuff, the script is disabled until I use a certain character in my game, which activates this script.

I do not know how what’s causing this issue and I have tried a few times in attempt but it seems too complicated for me, so I am asking help. If anyone would like to help, please do. I’d greatly appreciate the help received!

I am once again asking for help. I noticed the issue so far.


As seen in the video, as I changed the value, the new print statement I added shows to be the same. I do not know how to solve this problem either. This is also the new code.

local TRUEINSANITYHITS = workspace.TRUEINSANITYHITS
local SS = game:GetService("ServerStorage")
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = replicatedStorage.TRUEINSANITYWINNER
local FIGHTBUTTON = SS.FightButton
local players = game:GetService("Players")
local music = workspace.Lethalovania

local function THEBARRIERCONQUERED()
	print("THE PLAYER HAS CONQUERED THE TRUE BARRIER")
	music.Looped = false
	music:Stop()
	local sans = players:FindFirstChildOfClass("Player")
	local backpack = sans.Backpack
	if sans.TeamColor == BrickColor.new("Navy blue") then
		local character = sans.Character
		if character:FindFirstChildWhichIsA("Tool") then -- IF PLAYER IS ABUSING A BUG, DESTROY CURRENT HOTBAR REGARDLESS
			character:FindFirstChildWhichIsA("Tool"):Destroy()
		end
		for _, backpackItems in pairs (sans.Backpack:GetChildren()) do
			backpackItems:Destroy()
		end
		remoteEvent:FireAllClients()
	end
end

while TRUEINSANITYHITS.Value <= 14 do
	repeat 
		local FIGHTBUTTONCLONE = FIGHTBUTTON:Clone()
		FIGHTBUTTONCLONE.Parent = workspace
		FIGHTBUTTONCLONE.Script.Enabled = true
		print(TRUEINSANITYHITS.Value)
		task.wait(3)
	until TRUEINSANITYHITS.Value >= 15
	THEBARRIERCONQUERED()
	break
end

All I’m asking is for help. I really need it. I’d greatly appreciate the help received, as this bug is beyond annoying to fix.

I don’t think you need a while loop and a repeat loop.

Pick one:

--while TRUEINSANITYHITS.Value <= 14 do
	repeat 
		local FIGHTBUTTONCLONE = FIGHTBUTTON:Clone()
		FIGHTBUTTONCLONE.Parent = workspace
		FIGHTBUTTONCLONE.Script.Enabled = true
		print(TRUEINSANITYHITS.Value)
		task.wait(3)
	until TRUEINSANITYHITS.Value >= 15
	THEBARRIERCONQUERED()
	--break
--end

Both is fine.

I’d like to say something, I overreacted. The buttons do work, it’s just that I can’t modify the value in local. In theory, the script works entirely fine. Unforunately sorry. In summary, I don’t have any real problems besides the PlayerGUI not showing up for everyone.