local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local function createHitbox(player)
local hitbox = Instance.new("Part")
hitbox.Size = Vector3.new(7, 7, 7)
hitbox.Color = Color3.fromRGB(255, 255, 255)
hitbox.Anchored = true
hitbox.CanCollide = false
hitbox.Parent = Workspace
local character = player.Character or player.CharacterAdded:Wait()
hitbox.Position = character.PrimaryPart.Position
return hitbox
end
local function onPlayerAdded(player)
local hitbox = createHitbox(player)
player.CharacterAdded:Connect(function(character)
hitbox.Position = character.PrimaryPart.Position
end)
local function onHit(other)
if other:IsA("Tool") and (other.Name == "Knife" or other.Name == "Gun")
then
-- Implement the logic for stabbing or shooting
print(player.Name .. " hit " .. other.Parent.Name)
end
end
hitbox.Touched:Connect(onHit)
end
Players.PlayerAdded:Connect(onPlayerAdded)
for _, player in ipairs(Players:GetPlayers()) do
onPlayerAdded(player)
end