Objective Score Package

A single script that checks each player’s score once per second and fires an event if the objective score has been reached. Can be used to end a round once a player reaches X number of kills.

Note: This package is designed to work with the template gun games and relies on the default scoreScript to check the “score” property.

SETUP

  • Install the Objective Score package from the community tab.
  • Add the objectiveScoreScript to your User template.
  • Set the objective score property.
  • Set the event(s) you’d like to fire when the objective score is reached. To use this as a way to end a round in one of the template gun games, see the configuration image below.

And for those interested in the code, here it is:

local ObjectiveScoreScript = {}

ObjectiveScoreScript.Properties = {
	{ name = "objectiveScore", type = "number",},
	{ name = "onObjectiveScore", type = "event", },
}

function ObjectiveScoreScript:Init()
	self:Schedule( function()
		while true do
	        Wait(1.0)
			if self:GetEntity():FindScriptProperty("score") >= self.properties.objectiveScore then
				self.properties.onObjectiveScore:Send()
			end
		end
   end)
end

return ObjectiveScoreScript
1 Like