Here's a script specifically designed to work with ACS (Advanced Combat System) for Roblox:
-- Server Script (place in ServerScriptService)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Create leaderstats for coins
local function createLeaderstats(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Value = 0
coins.Parent = leaderstats
end
-- Handle player joining
Players.PlayerAdded:Connect(createLeaderstats)
-- ACS Kill Detection
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
local player = Players:GetPlayerFromCharacter(character)
if not player then return end
-- Listen for ACS death
humanoid.Died:Connect(function()
-- Check for ACS killer tag
local killerTag = character:FindFirstChild("creator") or humanoid:FindFirstChild("creator")
if killerTag and killerTag.Value then
local killer = killerTag.Value
-- Make sure killer is a valid player and not the same as victim
if killer and killer ~= player and killer:FindFirstChild("leaderstats") then
local killerCoins = killer.leaderstats:FindFirstChild("Coins")
if killerCoins then
killerCoins.Value = killerCoins.Value + 100
print(killer.Name .. " earned 100 coins for killing " .. player.Name .. " with ACS!")
end
end
end
end)
end
-- Connect to existing and new players
for _, player in pairs(Players:GetPlayers()) do
if player.Character then
onCharacterAdded(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(onCharacterAdded)
end)
This script works with ACS because:
- ACS Creator Tags: ACS automatically creates "creator" tags when players are killed by ACS weapons
- Automatic Detection: The script listens for the Humanoid.Died event and checks for the creator tag
- Coin Rewards: When a valid kill is detected, it awards 100 coins to the killer
The script will automatically detect kills from any ACS weapon (guns, explosives, etc.) without needing any modifications to your ACS setup. Just place this script in ServerScriptService and it should work with your existing ACS weapons!
If you want to adjust the coin amount or add different rewards for different weapon types, let me know!