Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My goal sound script won't work. Why?

Asked by 10 years ago
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

Log in to vote
0
Answered by
Asirix 15
10 years ago

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.

0
Ok, thank you Roboy5857 20 — 10y
Ad
Log in to vote
0
Answered by
bobder2 135
10 years ago
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

Log in to vote
0
Answered by 10 years ago

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

Answer this question