Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to add and stop audio like in speed run 4?

a friend told me to try and make a speed run game and i want to add audio in it like in speed run 4 like how the audio starts when the check point is walked on by the player and ends when you get to the next stage

1 comment

0

Have you tried making parts where the end and start is to your game. when player runs on the start button it will start making sound. Same with end button.

1 answer

✓ Accepted answer

The easiest way is to create a part that when the player touches activates the audio and another part when the player touches stops the audio

create a folder for all your audio for each stage

also this function will reduce the amount of code you use each time

local function music (startpart, endpart, audio)
	local function STouch(part)
		if part.Parent ~= nil then
			local h = part.Parent:findFirstChild("Humanoid")
			if h~=nil then
				audio:Play() -- plays audio if a player touches the start checkpoint
			end
		end
	end
	startpart.Touched:connect(STouch)
	local function FTouch(part)
		if part.Parent ~= nil then
			local h = part.Parent:findFirstChild("Humanoid") -- checks if its a player that touches it
			if h~=nil then
				audio:Stop() -- stops audio is player touches the finish checkpoint
			end
		end
	end
	endpart.Touched:connect(FTouch) -- listens out for touching ppl
end

-- example of how you would put the checkpoints 1st comes start, 2nd finish , 3rd audio you wanna play
music(game.Workspace.Start,game.Workspace.Finish,game.Workspace.Music["Relaxed African Bush"])

if anything doesnt work tell me please i did this in the morning - but i have personally tested the script and it works

This discussion is preserved as it was. New answers, comments, and votes are closed.