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

What is wrong with this script? (Sound played on damage)

Asked by 10 years ago

It's my first time writing a script from scratch, but it wont work, and I get an error. Any idea on how to fix? This is will be used for my Serious Sam game, by the way.

function() findfirstchild(Humanoid)
    if humanoid.Health = -50 -- If the player looses 50 health, then the sound in the script will play only for a split second.
        then
        sound3:(play)
        wait(0.5)
        sound3:(stop)
    end
end


if findfirstchild(Humanoid)
    if humanoid.Health = -25
        then
        sound2:(play)
            sound2:(play)
        wait(0.5)
        sound2:(stop)
    end
end


if findfirstchild(Humanoid)
    if humanoid.Health = -10
        then
        sound1:(play)
            sound1:(play)
        wait(0.5)
        sound1:(stop)
    end
end


if findfirstchild(Humanoid)
    if humanoid.Health = -75
        then
        sound4:(play)
            sound3:(play)
        wait(0.5)
        sound4:(stop)
    end
end

1 answer

Log in to vote
1
Answered by 10 years ago

If the if ___ then statement you need a "==" or "~="(Only for some things though.) Don't forget... You need to put little, "Variables" (I think it's called) for example...

sound1 = game.Workspace.Death--Or players or soundscape...

Also Function by its self won't work.

function onTouch(part) -- Lava
local humanoid = part.Parent:FindFirstChild("Humanoid") 
if (humanoid ~= nil) then
humanoid.Health = 0
end 
end
script.Parent.Touched:connect(onTouch)

I fixed some of it. I don't know If you want it too scan or anything...

function()
findfirstchild(Humanoid)
if humanoid.Health == -50 then
sound3:(play)
wait(0.5)
sound3:(stop)
end
end
if findfirstchild(Humanoid)
if humanoid.Health == -25 then
sound2:(play)
wait(0.5)
sound2:(stop)
end
end
if findfirstchild(Humanoid)
if humanoid.Health == -10 then
sound1:(play)
wait(0.5)
sound1:(stop)
end
end
if findfirstchild(Humanoid)
if humanoid.Health == -75 then
sound4:(play)
wait(0.5)
sound4:(stop)
end
end
0
Yes. I want it to scan for a change in the Humanoid's health. TheRings0fSaturn 28 — 10y
0
Yes but you also have other mistakes in your script too. You can go to wiki if it helps. EzraNehemiah_TF2 3552 — 10y
0
Hmm...I don't know how to program it, though. It's my first script. lol TheRings0fSaturn 28 — 10y
0
I see... Here look at this link, see if it helps. http://wiki.roblox.com/index.php?title=Function_Dump EzraNehemiah_TF2 3552 — 10y
Ad

Answer this question