Take a look at some code

Alright so I am testing out a Murder server with PS on it. I want to give the winner points on round end. Here’s the current code:

local murderer = ply:GetMurderer
local bystander = ply:GetBystander

hook.Call( "OnEndRound", "RoundEnd", function()
function RoundWin( murderer, bystander )
        if self.RoundStage !=1 then 
                murderer:PS_GivePoints( 50 ) and murderer:Notify( "Nice Killing!" ) else if
                    self.RoundStage !=2 or self.RoundStage !=3
						then bystander:PS_GivePoints( 50 ) and bystander:Notify("Great Job, you lived!" )

Keep in mind I’m shitty when it comes to coding so any constructive criticism will be noted. Did I mess up somewhere? On what? Also should be run server or clientside?

  1. Should be hook.Add.
  2. I’m assuming ply:GetMurderer/Bystander are methods, so you should put parenthesis () after them.
  3. For hooks where you paste the function directly in, you shouldn’t have

function RoundWin()

but rather, just function().

  1. Since murderer and bystander are defined at the top, you don’t need to include them in the function.

  2. Your indention and line breaks are a bit wonky.


I ended up writing this for someone a few hours ago; try this.

local MPoints = 20  -- Amount murderers get for killing bystanders
local BPoints = 20  -- Amount bystanders get for killing murderes

function PS_RoundGive(reason, murderer)
    if (reason == 1) then
        for k, v in pairs(player.GetAll()) do
            if v:GetMurderer() then
            v:PrintMessage(HUD_PRINTTALK, "Murderer won!")
    elseif (reason == 2 or reason == 3) then
        for k, v in pairs(player.GetAll()) do
            if not v:GetMurderer() then
            v:PrintMessage(HUD_PRINTTALK, "Bystanders won!")
hook.Add("EndTheRound", "PS_RoundGive", PS_RoundGive)