#need help to make my hit box script for my punch

1 messages · Page 1 of 1 (latest)

cloud delta
#

need help

#

trying to make the red invisable

left zinc
#

set its transparency to 1

cloud delta
#

ik

#

it is

#

@left zinc

left zinc
#

well its clearly not

#

since its visible

cloud delta
#

-- ServerScriptService/HitboxHandler.lua

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")

local MainEvent = ReplicatedStorage:WaitForChild("MainEvent")

MainEvent.OnServerEvent:Connect(function(plr)
if not plr.Character then return end
local hrp = plr.Character:FindFirstChild("HumanoidRootPart")
local humanoid = plr.Character:FindFirstChildOfClass("Humanoid")
if not hrp or not humanoid then return end

-- Slow the player
humanoid.WalkSpeed = 7
task.delay(0.65, function()
    if humanoid then humanoid.WalkSpeed = 16 end
end)

-- 1) Spawn an invisible server-side hitbox for damage detection
local hitbox = Instance.new("Part")
hitbox.Name         = "ServerPunchHitbox"
hitbox.Size         = Vector3.new(6, 6, 4)
hitbox.CFrame       = hrp.CFrame * CFrame.new(0, 0, - (hitbox.Size.Z/2 + 1))
hitbox.Anchored     = true
hitbox.CanCollide   = false
hitbox.Transparency = 1    -- Fully invisible
hitbox.Material      = Enum.Material.SmoothPlastic  -- Optional for material
hitbox.BrickColor    = BrickColor.new("Institutional white")  -- Invisible color
hitbox.Parent       = workspace
Debris:AddItem(hitbox, 0.3)    -- lasts 0.3s

-- 2) Damage detection
local region = Region3.new(
    hitbox.Position - hitbox.Size/2,
    hitbox.Position + hitbox.Size/2
):ExpandToGrid(4)
for _, part in ipairs(workspace:FindPartsInRegion3(region, plr.Character, 50)) do
    local otherHum = part.Parent:FindFirstChildOfClass("Humanoid")
    if otherHum and otherHum ~= humanoid then
        otherHum:TakeDamage(10)
    end
end

end)

#

-- LocalScript → StarterCharacterScripts

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")

local MainEvent = ReplicatedStorage:WaitForChild("MainEvent")
local player = Players.LocalPlayer
local char, hrp, humanoid

-- Utility to refresh your character references
local function refreshCharacter()
char = player.Character or player.CharacterAdded:Wait()
hrp = char:WaitForChild("HumanoidRootPart")
humanoid = char:WaitForChild("Humanoid")
end

refreshCharacter()
player.CharacterAdded:Connect(refreshCharacter)

-- Listen for your punch input
UserInputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
-- 1) Spawn an invisible hitbox locally
local box = Instance.new("Part")
box.Name = "LocalPunchHitbox"
box.Size = Vector3.new(6, 6, 4)
box.CFrame = hrp.CFrame * CFrame.new(0, 0, - (box.Size.Z/2 + 1))
box.Anchored = true
box.CanCollide = false
box.Transparency = 1 -- Fully invisible (this is crucial)
box.Material = Enum.Material.SmoothPlastic -- Optional: SmoothPlastic material
box.BrickColor = BrickColor.new("Institutional white") -- Invisible color, no effect on visibility
box.Parent = workspace
Debris:AddItem(box, 0.3) -- lasts 0.3s

    -- 2) Tell the server you punched (for damage, slow, etc)
    MainEvent:FireServer()
end

end)

dark juniper
cloud delta
#

;-- LocalScript → StarterCharacterScripts

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")

local MainEvent = ReplicatedStorage:WaitForChild("MainEvent")
local player = Players.LocalPlayer
local char, hrp, humanoid

-- Utility to refresh your character references
local function refreshCharacter()
char = player.Character or player.CharacterAdded:Wait()
hrp = char:WaitForChild("HumanoidRootPart")
humanoid = char:WaitForChild("Humanoid")
end

refreshCharacter()
player.CharacterAdded:Connect(refreshCharacter)

-- Listen for your punch input
UserInputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
-- 1) Spawn an invisible hitbox locally
local box = Instance.new("Part")
box.Name = "LocalPunchHitbox"
box.Size = Vector3.new(6, 6, 4)
box.CFrame = hrp.CFrame * CFrame.new(0, 0, - (box.Size.Z/2 + 1))
box.Anchored = true
box.CanCollide = false
box.Transparency = 1 -- Fully invisible (this is crucial)
box.Material = Enum.Material.SmoothPlastic -- Optional: SmoothPlastic material
box.BrickColor = BrickColor.new("Institutional white") -- Invisible color, no effect on visibility
box.Parent = workspace
Debris:AddItem(box, 0.3) -- lasts 0.3s

    -- 2) Tell the server you punched (for damage, slow, etc)
    MainEvent:FireServer()
end

end)