For the longest time, I can't find a way to make trigger blocks. For example, when a player touches a part that was put there as a way to track and know where they are. Problem is that im trying to make the audio change and when a player touches the block, it really messes up as it triggers 100s of times. I need a way to get something to trigger only once and be re-triggerable.

Heres what I tried but I can't use it anymore.

-- Variables
script:WaitForChild("Location")
script:WaitForChild("Sounds")
script:WaitForChild("Available")
local Humaniod = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local track1 = game.Workspace.TrackWall1.Track1

TrackedNear = false
Prepared = false
Triggered = false

range = 10

--Wall Others
otherwise1 = false

if script.Available == false then
	script:Destroy()
else
	while true do
	 wait()--Tracking	
	
		--Track Wall 1	
		if (track1.Position - Humaniod.Position).magnitude < range then
		Prepared = true
		range = 5
		if Prepared == true then
			TrackedNear = true
			if otherwise1 == false then
				--Player is walking in.
				game.Workspace.TrackWall1.TrackIn.Touched:Connect(function()
					script.Location = 1
					print("Player has entered")
					range = 10
				end)
				otherwise1 = true
			elseif otherwise1 == true then
				game.Workspace.TrackWall1.TrackIn.Touched:Connect(function()
					script.Location = 0
					print("Player has Left")
					range = 10
				end)
				otherwise1 = false
			end
		end
		end
		--End 1
	
	end
end

2 comments

0

use a debounce variable