Jump to content

Sound Playing in FPS Player Script


Sargeant12344
 Share

Recommended Posts

I'm trying to make a heart flatlining sound and edited my respawn trigger and FPS Player Script, however when I try to test the script, no sound plays. Rather than post the whole FPS Player script I only posted the used bits.

 

--Load shared sounds
self.sound={}--table to store sound in
self.sound.flashlight=Sound:Load("Sound/Player/flashlight_02_on.wav")
self.sound.damage={}
self.sound.damage[1]=Sound:Load("Sound/Impact/body_punch_03.wav")
self.sound.damage[2]=Sound:Load("Sound/Impact/body_punch_04.wav")
self.sound.pickupweapon=Sound:Load("Sound/Player/pickupammo.wav")
self.sound.footsteps={}
self.sound.footsteps.concrete={}
self.sound.footsteps.concrete.step={}
self.sound.footsteps.concrete.step[1] = Sound:Load("Sound/Footsteps/Concrete/step1.wav")
self.sound.footsteps.concrete.step[2] = Sound:Load("Sound/Footsteps/Concrete/step2.wav")
self.sound.footsteps.concrete.step[3] = Sound:Load("Sound/Footsteps/Concrete/step3.wav")
self.sound.footsteps.concrete.step[4] = Sound:Load("Sound/Footsteps/Concrete/step4.wav")
self.sound.footsteps.concrete.jump = Sound:Load("Sound/Footsteps/Concrete/jump.wav")
self.sound.music={}
self.sound.music = Sound:Load("Sound/Music/Heart")
self.bloodoverlay={}
self.entity:SetPickMode(0)

 

Script.heartFlatlining = false

 

function Script:HeartFlatlining()
if script.heartFlatlining == true then
 self.sound.damage[math.random(#self.sound.damage)]:Play()
end
end

 

Script.respawnPoint = "" --entity "Respawn point"

 

function Script:Collision(entity, position, normal, speed)

if(entity:GetKeyValue("name") == "Player") then

spawnPos = self.respawnPoint:GetPosition()

entity:SetPosition(spawnPos)

spawnRot = self.respawnPoint:GetRotation()

entity.script.camRotation = spawnRot

entity.script.heartFlatlining = true

else

entity:Release()

end

end

 

Thanks

Link to comment
Share on other sites

if script.heartFlatlining == true then

 

It is declared with Script.heartFlatlining so you access it with self.heartFlatlining within the same script.

 

if self.heartFlatlining == true then

---

Scott

 

Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...