local P=.4 local p=3.1 local W=game.Players.LocalPlayer game.ReplicatedStorage.Interactions.Client.Perks.ShowFootsteps.OnClientEvent:connect(function(u)if W.Character~=nil then local Y=W.PlayerScripts.Functions.GetRayIgnoreList:Invoke()for u,f in pairs(u)do local h=f.Character if h:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")and f~=W then local u=false local f=P local O=Color3.fromHSV(math.random(),1,1)spawn(function()while wait(f)do if h.Parent==nil or h:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")==nil then break end local b=Ray.new(h.HumanoidRootPart.Position,Vector3.new(0,-p,0))local K,n=workspace:FindPartOnRayWithIgnoreList(b,Y,false,true)if K~=nil and h.HumanoidRootPart.Velocity.Magnitude>1 then local p if u then p=h.HumanoidRootPart.CFrame*CFrame.new(-0.5,-2.95,0)u=false else p=h.HumanoidRootPart.CFrame*CFrame.new(.5,-2.95,0)u=true end W.PlayerScripts.Functions.PlaceFootstep:Fire(p,O,h.Humanoid)f=P else f=.033 end end end)end end end end)
-- Basic settings
local FOOTSTEP_PLACEMENT_RATE = 0.4
local GROUND_DETECTION_DISTANCE = 3.1

local plr = game.Players.LocalPlayer

game.ReplicatedStorage.Interactions.Client.Perks.ShowFootsteps.OnClientEvent:connect(function(plrs)
	-- Make sure character is alive
	if plr.Character ~= nil then
		-- Set up detection part for each player
		local ignore = plr.PlayerScripts.Functions.GetRayIgnoreList:Invoke()
		for _, i in pairs(plrs) do
			local thisChr = i.Character
			if thisChr:FindFirstChild("HumanoidRootPart") and i ~= plr then
				local left = false
				local waitTime = FOOTSTEP_PLACEMENT_RATE
				local color = Color3.fromHSV(math.random(), 1, 1)
				spawn(function()
					while wait(waitTime) do
						-- Check if detection part is gone or owner is gone
						if thisChr.Parent == nil or thisChr:FindFirstChild("HumanoidRootPart") == nil then
							break
						end

						-- Check if should place a foot step
						local ray =
							Ray.new(thisChr.HumanoidRootPart.Position, Vector3.new(0, -GROUND_DETECTION_DISTANCE, 0))
						local hit, hitPos = workspace:FindPartOnRayWithIgnoreList(ray, ignore, false, true)
						if hit ~= nil and thisChr.HumanoidRootPart.Velocity.Magnitude > 1 then
							-- Tell the owner to place a footstep
							local cfr
							if left then
								cfr = thisChr.HumanoidRootPart.CFrame * CFrame.new(-0.5, -2.95, 0)
								left = false
							else
								cfr = thisChr.HumanoidRootPart.CFrame * CFrame.new(0.5, -2.95, 0)
								left = true
							end
							plr.PlayerScripts.Functions.PlaceFootstep:Fire(cfr, color, thisChr.Humanoid)

							-- Set wait time to be the placement rate
							waitTime = FOOTSTEP_PLACEMENT_RATE
						else
							-- Set wait time to be quick
							waitTime = 0.033
						end
					end
				end)
			end
		end
	end
end)
