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
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