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

My goal sound script won't work. Why?

Goal = game.Workspace.Goal
Ball = game.Workspace.Ball
Message = game.Workspace.Message
Text = Message.Text
GoalSound = game.Workspace.GoalSound
SoundID = GoalSound.SoundId
BoooSound = game.Workspace.BoooSound
SoundID = BoooSound,SoundId

function BallToGoal()
function onTouched(Goal)
end	
end

Ball:onTouched(Goal) -- Defining line 8
if Ball:onTouched(Goal) == true then
	Message.Text = "GOAL!!!"
	wait(0.05)
	GoalSound.SoundID = "http://www.roblox.com/Eminem-Im-Not-Afraid-item?id=131149175"
	GoalSound.SoundID:Play()
	GoalSound.SoundID:Stop()
	wait(5) -- After 5, The message will be destroyed
	Message.Text:Destroy()
else
	if Ball:onTouched(Goal) == false then
		Message.Text = "Whoa, that sucked!"
		BoooSound.SoundID:Play()
		wait(7)
		BoooSound.SoundID:Stop()
		wait(5) -- Same thing with line 22
		Message.Text:Destroy()
	end
end

This script is for a soccer game. So the script is like, when the ball touches the goal.. There is a message that says "GOAL!!!" and has a sound to it. If it doesn't, It says "Whoa, that sucked!" thats if Ball:onTouched(Goal) would equal to false. Any help?

3 answers

✓ Accepted answer

You're basically looping. DO this.

GoalSound.SoundID:Play()
Wait(5) -- or however long you want it to play.
GoalSound.SoundID:Stop()

Also use elseif not else and if.

1 comment

0

Ok, thank you

GoalSound = game.Workspace.GoalSound
SoundID = GoalSound.SoundId
BoooSound = game.Workspace.BoooSound
SoundID = BoooSound,SoundId

You have two variables named SoundID. You also put a comma instead of a period for the BoooSoundID

GoalSound = game.Workspace.GoalSound
GoalSoundID = GoalSound.SoundId
BoooSound = game.Workspace.BoooSound
BoooSoundID = BoooSound.SoundId

That's what it should look like

for soundID dont put the link, put the name of the sound in your workspace.

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