How Would I Go About Cloning My Bounty System?

hello! im making a bounty system where players can put bounty’s on players and if you were to take the job and kill the player with the bounty you would get a cash reward, or the server will sometimes randomly put bounty’s on players. However i have come to a roadblock with this system. Im not sure how to script the templates. i want all players to be able to see the same bounty jobs, and i still want actions to be cloned to all players. for example, when a player completes a bounty i want the bounty template to be deleted off bounty scrolliingFrame for everyone so no other can do this. how would i do this?

– server script for reference

local players = game:GetService("Players")

local mechanics = game:GetService("ReplicatedStorage"):FindFirstChild("mechanics")
local notifyOnServerEvent = mechanics:WaitForChild("notifications"):WaitForChild("NotifyOnServer")


players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		
		local hitmanFolder = Instance.new("Folder")
		hitmanFolder.Name = "hitmanFolder"

		local killedByValue = Instance.new("ObjectValue")
		killedByValue.Name = "killedBy"
		killedByValue.Value = nil
		killedByValue.Parent = character
		
		local isDoingHitman = Instance.new("BoolValue")
		isDoingHitman.Name = "isDoingHitman"
		isDoingHitman.Value = false
		isDoingHitman.Parent = hitmanFolder
		
		local hitmanReward = Instance.new("NumberValue")
		hitmanReward.Name = "hitmanReward"
		hitmanReward.Value = 0
		hitmanReward.Parent = hitmanFolder
		
		local hitmanTarget = Instance.new("ObjectValue")
		hitmanTarget.Name = "hitmanTarget"
		hitmanTarget.Value = nil
		hitmanTarget.Parent = hitmanFolder
		
		local hitmanOwner = Instance.new("ObjectValue")
		hitmanOwner.Name = "hitmanOwner"
		hitmanOwner.Value = nil
		hitmanOwner.Parent = hitmanFolder
		
		isDoingHitman:GetPropertyChangedSignal("Value"):Connect(function()
			if isDoingHitman ==  false then
				hitmanTarget = nil
				hitmanReward = 0
			end
		end)
		
		local humnoid = character:FindFirstChild("Humanoid")
		
		humnoid.Died:Connect(function()
			local killer = killedByValue.Value
			local killerDoingHitman = killer:FindFirstChild("hitmanFolder"):FindFirstChild("isDoingHitman")
			local TargethitmanOwner = killer:FindFirstChild("hitmanFolder"):FindFirstChild("hitmanOwner")
			
			if killer then
				
				local target = killer:FindFirstChild("hitmanFolder"):FindFirstChild("hitmanTarget").Value

				if target == player then
					
				
					local playerKillerCash = killer:FindFirstChild("playerStats"):FindFirstChild("cash")
					local reward = killer:FindFirstChild("hitmanFolder"):FindFirstChild("hitmanReward").Value
					
					killerDoingHitman = false			
					
					if TargethitmanOwner ~= nil then
						local ownerCash = TargethitmanOwner:FindFirstChild("playerStats"):FindFirstChild("cash")
						
						ownerCash.Value = ownerCash.Value - reward
						playerKillerCash.Value = playerKillerCash.Value + reward
						
					elseif TargethitmanOwner == nil then
						playerKillerCash.Value = playerKillerCash.Value + reward
					end
					
					notifyOnServerEvent:FireClient(killer, "killed target", "positive")
						
					for _, otherPlayers in ipairs(players) do
						if otherPlayers ~= killer then
							
							local otherPlayersHitmanFolder = otherPlayers:FindFirstChild("hitmanFolder")
							local otherisDoingHitman = otherPlayersHitmanFolder:FindFirstChild("isDoingHitman")
							local otherhitmanTarget = otherPlayersHitmanFolder:FindFirstChild("hitmanTarget")

							if otherisDoingHitman.Value ==  true and otherhitmanTarget.Value == player then
								otherisDoingHitman.Value = false
								notifyOnServerEvent:FireClient(otherPlayers, "target has already been killed", "negative")
							end
						end
					end
				end
			end
		end)
	end)
end)

players.PlayerRemoving:Connect(function(player)
	for _, otherPlayers in ipairs(players) do
		local otherPlayersHitmanFolder = otherPlayers:FindFirstChild("hitmanFolder")
		local otherisDoingHitman = otherPlayersHitmanFolder:FindFirstChild("isDoingHitman")
		local otherhitmanTarget = otherPlayersHitmanFolder:FindFirstChild("hitmanTarget")
		
		if otherisDoingHitman.Value ==  true and otherhitmanTarget.Value == player then
			otherisDoingHitman.Value = false
			notifyOnServerEvent:FireClient(otherPlayers, "target has left the game", "negative")
		end
	end
end)

– bounty frame and a template example

1 Like