0% found this document useful (0 votes)
15 views1 page

Output Code

Hi

Uploaded by

rin71156
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Output Code

Hi

Uploaded by

rin71156
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

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

You might also like