[SOLVED] Debounce applies to all players

Hey guys. I am trying to get the medium fading parts (part that fades away when you step on it) to work for my obby. The issue is that the fading parts debounce will not work when multiple players step on it(when a player steps on the part right after another player, only the first player that stepped on the part will have the part fade away for them). The fading away is handled by a local script, and the debounce is handled on the server, which is necessary so that players don’t have to wait for the fading part to reappear from someone else. I have tried looking for other topics and I couldn’t find anything. Main point: How can I make sure that each player does not have to wait for other players for the fading part to fade away?(Not because the fading part disappears for everyone else, but because one player makes the debounce stay active until finished)

Part of Server Script:

--Medium Fading Part
			if object:HasTag("MediumFading") then

				object.Touched:Connect(function(hit)
					if hit.Parent:FindFirstChild("Humanoid") and hit:IsA("Part") then

						if not MediumFadingPartDebounce[object] then

							--print(MediumFadingPartDebounce[object])

							MediumFadingPartDebounce[object] = true

							--print(MediumFadingPartDebounce[object])

							local duration = 1
							local status = "Medium"
							local player = Players:GetPlayerFromCharacter(hit.Parent)


							fading:FireClient(player, object, status, duration)

							wait(duration + 1)
							MediumFadingPartDebounce[object] = nil

							--print(MediumFadingPartDebounce[object])

						end

					end
					
				end)


			end

Handle Fading Local Script:

local TweenService = game:GetService("TweenService")

local PortalRemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("Portal")
local PortalGuiFrame = script.Parent

local LimitPart = game.Workspace:WaitForChild("Lobby"):WaitForChild("AfterWinLimitPart")

local tweenInfo = TweenInfo.new(
	1,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.Out,
	0,
	true
)

local tween = TweenService:Create(PortalGuiFrame, tweenInfo, {BackgroundTransparency = 0})

PortalRemoteEvent.OnClientEvent:Connect(function()
	
	print("Activated")
	
	LimitPart.CanCollide = true
	
	PortalGuiFrame.Visible = true
	
	tween:Play()
	tween.Completed:Wait()
	
	PortalGuiFrame.Visible = false
	
	wait(0.5)
	
	LimitPart.CanCollide = true
	
end)

Thank you all

Instead of this it should be

MediumFadingPartDebounce[hit.parent]

This is because the object is the same for everyone and the hit.parent is unique since its the persons character

Actually, why do you need to use a local script to script a fading part?
You can just use a server script to make a fading part fade when touched. and then make a debounce into the part.

local cooldown = 2

if object:HasTag("MediumFading") then
    local deb = true

    object.Touched:Connect(function(hit)
        if game.Players:GetPlayerFromCharacter(hit.Parent) and deb then
            deb = false
            game:GetService('TweenService'):Create(object, TweenInfo.new(1), {Transparency = 1}):Play()
            wait(1)
            object.CanCollide = false
            wait(cooldown)
            object.Transparency = 0
            object.CanCollide = true
        end
    end)
end

I don’t want all of the players to have to wait for the fading part because of one player that stepped on it.

Problem is that I need the object index too. Without it, the debounce would apply to other fading parts at the same time, meaning stepping on one fading part will make all other fading parts not fade away until that specific fading part’s debounce is finished. Is there a way to keep track of which player and which fading part in the same hashmap?

I recommend checking this post I made about a week ago: Debounce Applies to all Parts at once

Update: I tried creating a hashmap that indexes the player that is added to the if statement “if not MediumFadingPartDebounce[object] then” using the keyword “and”, but it still doesn’t work.

After a lot of different trials and errors, I made the entire debounce system local