You can write your topic however you want, but you need to answer these questions:
Hello Developers, I’ve been trying to create a wanted system and I’m mostly having trouble giving the Player a wanted value to check if the player is wanted.
PROBLEM
I’ve tried to look for solutions, but not a single one is related to my problem.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
MODULE SCRIPT
module.wanted = function()
local mostKillsPlayer = calculateKills()
for _, player in pairs(game.Players:GetPlayers()) do
local wantedTag = player:FindFirstChild("Wanted")
local bounty = player:FindFirstChild("Bounty")
if wantedTag and bounty then
if player ~= mostKillsPlayer or (player == mostKillsPlayer and wantedTag.Parent ~= player and bounty.Parent ~= player) then
wantedTag:Destroy()
bounty:Destroy()
end
elseif player == mostKillsPlayer then
task.wait(0.5)
if not wantedTag or player:FindFirstChild("Wanted") then
local content = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
local newWantedTag = Instance.new("BoolValue")
newWantedTag.Name = "Wanted"
newWantedTag.Parent = player
if player.Character then
player.Character.Humanoid.Died:Connect(function() --reset the wanted player on death
if player:FindFirstChild("Wanted") then
player.ServerKills.Value = 0
end
end)
end
--[[
workspace.Wanted.WantedBillboard.Side1.SurfaceGui.Username.Text = player.Name
workspace.Wanted.WantedBillboard.Side2.SurfaceGui.Username.Text = player.Name
workspace.Wanted.WantedBillboard.Side1.SurfaceGui.ImageLabel.Image = content
workspace.Wanted.WantedBillboard.Side2.SurfaceGui.ImageLabel.Image = content
]]
end
end
end
end
SERVER SCRIPT
local debounce = {}
game.Players.PlayerAdded:Connect(function(player)
debounce[player] = false
player.CharacterAdded:Connect(function()
serverFunctions.wanted()
updateBounty(player)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
serverFunctions.wanted()
updateBounty(player)
local wanted = player:FindFirstChild("Wanted")
local bounty = player:FindFirstChild("Bounty")
if wanted then
wanted:Destroy()
end
if bounty then
bounty:Destroy()
end
end)
game:GetService("RunService").Stepped:Connect(function()
for _, player in pairs(game.Players:GetPlayers()) do
if not debounce[player] then
debounce[player] = true
serverFunctions.wanted()
updateBounty(player)
task.wait(1)
debounce[player] = false
end
end
end)