Best way to handle a variety of killstreak items

I just wanna know if the way I am organising my killstreak code is a good and efficient way of doing so. Basically, when a player uses a killstreak, it checks on the server to make sure they have the item available, then if it returns true, the client requires the module and does module.Use() to use the item

image

Example of killstreak code

local Grenade = {}

local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

local GrenadeItem = script:WaitForChild("Grenade")

local Player = Players.LocalPlayer

local GameSettings = ReplicatedStorage:WaitForChild("GameSettings")

local Camera = workspace.CurrentCamera

local SPEED = 3
local EXPLODE_TIME = 1
local RADIUS = 20

--// Use the radar streak
function Grenade.Use()
	local GrenadeItem = GrenadeItem:Clone()
	GrenadeItem.BrickColor = Player.TeamColor
	
	GrenadeItem.Parent = workspace
	
	GrenadeItem.CFrame = Camera.CFrame
	GrenadeItem:ApplyImpulse(GrenadeItem.CFrame.LookVector * SPEED)
	
	delay(EXPLODE_TIME, function()
		GrenadeItem.Anchored = true
		
		local Explode = GrenadeItem:Clone()
		Explode.CanCollide = false
		
		Explode.Parent = workspace
		
		local ExplodeTween = TweenService:Create(
			Explode,
			TweenInfo.new(1),
			{
				Size = Vector3.new(RADIUS, RADIUS, RADIUS),
				Transparency = 1
			}
		)
		ExplodeTween:Play()
		
		local Teams = GameSettings:GetAttribute("Teams")
		
		-- Check radius of players
		for _, player in pairs(Players:GetPlayers()) do
			if player == Player then continue end -- Don't affect ourselves
			
			if player.Team == Player.Team and Teams then continue end -- Don't affect team mates
			
			local Character = player.Character
			if not Character then continue end
			
			if (player.Character.HumanoidRootPart.Position - GrenadeItem.Position).Magnitude <= RADIUS then
				local Creator = Instance.new("ObjectValue")
				Creator.Name = "Creator"
				Creator.Value = Player.Character
				Creator.Parent = Character.Humanoid
				
				Debris:AddItem(Creator, 2)
				
				Character.Humanoid.Health = 0
			end
		end
		
		GrenadeItem:Destroy()
	end)
end

return Grenade

I am just afraid of players being easily able to exploit this system however. But since each killstreak has a different method of working (example here being)

Grenade needs to throw a grenade object
Radar needs to create billboard UI’s to show enemy players
Landmine the player needs to equip a landmine and be able to place

And trying to organise these different items in a way that’s clean and simple to use is where I’m struggling.

1 Like

If it’s the client calling the .Use() function, then it’s not going to replicate to other clients, so only the player who used the streak will see the grenade exploding.