toolUtil
A simple utility module for working with tools.
Functions
toolOwner
Attempts to returns the owner of the given tool, if found.
tryPlaceToolInBackpackAndStarterGear
Places the given tool in the given player
's backpack and a cloned variant of it in player.StarterGear
.
tryPlaceToolInBackpackAndEquip
Places the given tool in the given player
's backpack and tries to equips it on the humanoid.
mappedPlayerToolCount
Returns the player tool count. predicate
is called on every tool owned by the given player
, and each time it returns true
,
the tool count is incremented by 1.
playerTools
Returns a read only array of all player tools - both equipped and unequipped.
currentEquippedTool
Returns the current equipped tool by the player.
observePlayerForToolsEquippedAndUnequipped
toolUtil.
observePlayerForToolsEquippedAndUnequipped
(
) →
(
)
Observes the player for any new tools equipped or unequipped. Also captures all the initial tool equipped.
toolUtil.observePlayerForEquippedTool(player, function(newToolEquipped)
end, function(newToolUnequipped)
end)
WARNING
This method will throw an error if both observerForToolEquipped
and observerForToolUnequipped
are not specified, at least any one of them must be specified.
observePlayerBackpackForTools
toolUtil.
observePlayerBackpackForTools
(
) →
(
)
Observes the player's backpack for any new tools added or removed. Also captures all initial tools in the player backpack.
toolUtil.observePlayerBackpackForTools(player, function(toolAdded)
end, function(toolRemoved)
end)
WARNING
This method will throw an error if both observerForToolAdded
and observerForToolRemoved
are not specified, at least any one of them must be specified.
observePlayerForToolOwnership
toolUtil.
observePlayerForToolOwnership
(
) →
(
)
Observes the player's backpack and character for any new tools added or removed.
toolUtil.observePlayerForToolOwnership(player, function(toolOwnershipGranted)
end, function(toolOwnershipRemoved)
end)
WARNING
This method will throw an error if both observerForToolOwnershipGranted
and observerForToolOwnershipRemoved
are not specified, at least any
one of them must be specified.