RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Can you write a script that creates a hitbox for a sword?"
-- server script local sword = script.Parent local hitbox = Instance.new("Part", sword) hitbox.Size = Vector3.new(3, 3, 3) -- You can change the size of the hitbox hitbox.Transparency = 1 -- Make the hitbox invisible hitbox.CanCollide = false -- Disable collisions hitbox.Anchored = true -- Keep the hitbox in place local weld = Instance.new("Weld", sword) weld.Part0 = sword weld.Part1 = hitbox weld.C0 = CFrame.new(0, 0, 1.5) -- You can change the position of the hitbox relative to the sword local function onHit(hit) local character = hit.Parent local humanoid = character:FindFirstChild("Humanoid") if humanoid then humanoid.Health = humanoid.Health - 10 -- You can change the damage amount end end hitbox.Touched:Connect(onHit)