Why is it overlapping?

I suggest you write it yourself instead of buying someone elses code because if you run into issues with code you’ve bought it’ll most likely be a pain to fix since these dudes on Fiverr or whatever are just complete ghosts when it comes to complaints :stuck_out_tongue:

I accidentally wrote buy, I got confused xd

I have an idea. I will put a ray under the character’s feet and this ray will play a sound every time it touches, so maybe it can be a more realistic sound system and I don’t have to deal with animation events.

I can send you a trial version when it’s done, if you want?

Sure I’d be happy too. Horror games are really my thing :smile:

This is inspired by Apierphobia, and backroom games right :thinking:

1 Like

Yeah, this game is a straight backrooms game. I’m thinking of making a lot of levels and mechanics

looking at the first script you sent, it looks like the problem is probably that you’re not clearing old track:GetMarkerReachedSignal("Footstep"):Connect() connections. every time you press shift, it creates another footstep connection, essentially running the same sound generation code multiple times.

to fix this, you’ll want to clear up any old Footstep marker connections before creating new ones. here’s an example (though it may not be perfect for whatever you’re trying to do):

local footstepConnection = nil -- var to keep track of existing connections

-- other code

Character.Humanoid.AnimationPlayed:Connect(function(track)
	
	if track.Name == "RunAnim" or track.Name == "WalkAnim" then 

		if footstepConnection then
			footstepConnection:Disconnect()
		end

		footstepConnection = track:GetMarkerReachedSignal("Footstep"):Connect(function() 
			
			local Material = castRay()
			
			print(Material)
			local Sounds = MaterialTable[Material].Sounds:GetDescendants()
			local RandomNumber = math.random(1, #Sounds)
			
			local RandomSound = Sounds[RandomNumber]
			
			local ClonedSound = RandomSound:Clone()
			ClonedSound.Parent = Character
			
			ClonedSound:Play()
			
			ClonedSound.Ended:Connect(function()
				ClonedSound:Destroy()
			end)
			
		end)
	end
end)

you may have to change things a bit to fit what you’re going for, but the main takeaway is that you can store connections in variables and then later disconnect them with variable:Disconnect()

2 Likes

yes it really worked… thanks a lot I didn’t think to disconnect!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.