Alright I literally have 3 debounces and I change the parent of the part that activates the script to workspace but the script still repeats itself. I have no idea whats going wrong, I placed debounces before every function but nothing works… Please help me
Here is the main part of the code that is being used (note I have a modulescript in which most of the functions are located)
elseif v.Name == "SinglePossibility" and detectorDebounce == "False" then
v.Touched:Connect(function(hit)
detectorDebounce = "True"
v.CanTouch = false
v.CanQuery = false
MainDetector = v
local OGvParent = v.Parent
v.Parent = workspace
local FigureDetector = v.FigureDetector
local jumpscarePossibilities = {}
local chosenJumpscare
for i, n in pairs(v.JumpscarePossibilities:GetChildren()) do
table.insert(jumpscarePossibilities, n.Name)
end
chosenJumpscare = jumpscarePossibilities[math.random(1, #jumpscarePossibilities)]
print("Chosen "..chosenJumpscare)
if(hit.Parent:FindFirstChild("Humanoid"))then
if vDebounce == "False" and chosenJumpscare == "shadowAppear" then
vDebounce = "True"
local character = hit.Parent
local humanoid = character.Humanoid
PlayerPart = character.HumanoidRootPart
jumpscareData.shadowAppear(PlayerPart, v, FigureDetector, FigureDetector.FigurePos, "North", "North")
PreviousJumpscare = chosenJumpscare
v.TimesActivated.Value += 1
vDebounce = "False"
elseif vDebounce == "False" and chosenJumpscare == "objectThrown" then
vDebounce = "True"
local character = hit.Parent
local humanoid = character.Humanoid
PlayerPart = character.HumanoidRootPart
jumpscareData.objectThrown(PlayerPart, v, FigureDetector, "Beans")
PreviousJumpscare = chosenJumpscare
v.TimesActivated.Value += 1
vDebounce = "False"
elseif vDebounce == "False" and chosenJumpscare == "shadowSighting" then
vDebounce = "True"
local character = hit.Parent
local humanoid = character.Humanoid
PlayerPart = character.HumanoidRootPart
jumpscareData.shadowSighting(PlayerPart, v, FigureDetector.FigurePos, LightGroup, "North")
PreviousJumpscare = chosenJumpscare
v.TimesActivated.Value += 1
vDebounce = "False"
end
end
v.CanTouch = true
v.CanQuery = true
v.Parent = OGvParent
detectorDebounce = "False"
end)