#Creating Hitboxes

1 messages · Page 1 of 1 (latest)

dire crown
#

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local mouse = player:GetMouse()

function onTouch(otherPart)
local character = otherPart.parent

if character then
    local humanoid = character:FindFirstChild("Humanoid")
    if humanoid then
        humanoid:TakeDamage(25)
    end
end

end

function m1()
local humanoidRoot = character:WaitForChild("HumanoidRootPart")
local playerSize = character:GetExtentsSize()
local hitbox = Instance.new("Part")
hitbox.Parent = workspace
hitbox.Size = Vector3.new(playerSize.X, playerSize.Y, 10)

hitbox.CFrame = humanoidRoot.CFrame * CFrame.new(0, 0, -10)
hitbox.Name = player.Name .. "'s m1 Hitbox"
hitbox.Color = BrickColor.Red()
hitbox.Material = Enum.Material.ForceField
hitbox.CanCollide = false
hitbox.Anchored = true

hitbox.Touched:Connect(onTouch)

task.wait(1)
hitbox:Destroy()

end

function generateHitboxes()
for hitboxesGenerated = 1, 20 do
m1()
task.wait(0.05)

end

end
mouse.Button1Down:Connect(generateHitboxes)

Can someone help me? This is experimental so ill do immunity and a local version later, but for now, i put this in ServerScriptService and it just doesn't do anything. I also tried a local script in starterplayerscripts but then it just ignores the color, material, can collide, anchored or auto-destroy.

velvet pumiceBOT
#

studio** You are now Level 3! **studio

glad pawn
dire crown
#

but how can i fix the local script bug?

#

when i put it in starterplayerscript as a localscript, it generates the box but then it just ignores the color, material, can collide, anchored or auto-destroy.

glad pawn
glad pawn
dire crown
#

hitbox.Color = Color3.fromRGB(255, 0, 0)

would this be better?

ivory ivy
dire crown
#

i'm a beginner so im still learning about replicatedstorage but thanks for the tip!