What the fuck is wrong with CreateSound()?

My code (client-side):


heartBeat = CreateSound(LocalPlayer, "player/heartbeat1.wav")
	heartBeat:Play()
	heartBeat:ChangeVolume(0, 0.1)

My errors client-side:



[ERROR] gamemodes/darkrp/gamemode/modules/hud/cl_init.lua:6: Tried to use a NULL entity!
  1. CreateSound - [C]:-1
   2. unknown - gamemodes/darkrp/gamemode/modules/hud/cl_init.lua:6
    3. include - [C]:-1
     4. LoadModules - gamemodes/darkrp/gamemode/cl_init.lua:22
      5. unknown - gamemodes/darkrp/gamemode/cl_init.lua:37


What the hell is wrong with this shit?

It’s LocalPlayer(), it is a function, not a simple variable.

LocalPlayer should be a function

[editline]20th May 2015[/editline]

Ninja’d

Same shit.


	heartBeat = CreateSound(LocalPlayer(), "player/heartbeat1.wav")
	heartBeat:Play()
	heartBeat:ChangeVolume(0, 0.1)


[ERROR] gamemodes/darkrp/gamemode/modules/hud/cl_init.lua:1: Tried to use a NULL entity!
  1. CreateSound - [C]:-1
   2. unknown - gamemodes/darkrp/gamemode/modules/hud/cl_init.lua:1
    3. include - [C]:-1
     4. LoadModules - gamemodes/darkrp/gamemode/cl_init.lua:22
      5. unknown - gamemodes/darkrp/gamemode/cl_init.lua:37


when do you run it? it will return nil until it’s like, created

Oh, looks like I got it. On plain cl_init.lua

LocalPlayer() will return NULL until all entities have been initialized. See GM:InitPostEntity.

Thanks. Solved.

So it looks like there isnt anything wrong with CreateSound