0% found this document useful (0 votes)
24 views2 pages

Local Script Do Soco

This script enables a punching mechanic in a Roblox game, where a player can perform a punch animation and sound effect when clicking the mouse. It creates a transparent punch part that detects collisions with other players' humanoids, dealing damage through a remote event. The script includes a debounce feature to prevent multiple punches from being executed in quick succession.
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)
24 views2 pages

Local Script Do Soco

This script enables a punching mechanic in a Roblox game, where a player can perform a punch animation and sound effect when clicking the mouse. It creates a transparent punch part that detects collisions with other players' humanoids, dealing damage through a remote event. The script includes a debounce feature to prevent multiple punches from being executed in quick succession.
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
You are on page 1/ 2

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent = ReplicatedStorage:WaitForChild("PunchDamage")

local player = game.Players.LocalPlayer


local mouse = player:GetMouse()
local tool = script.Parent

local debounce = false


local punchAnimation = Instance.new("Animation")
punchAnimation.AnimationId = "rbxassetid://72174331131009" -- troca se quiser

local punchSound = Instance.new("Sound")


punchSound.SoundId = "rbxassetid://8595980577"
punchSound.Volume = 1
punchSound.Name = "PunchSound"

local character, humanoid, animator, animationTrack

tool.Equipped:Connect(function()
character = player.Character or player.CharacterAdded:Wait()
humanoid = character:WaitForChild("Humanoid")

if not character:FindFirstChild("PunchSound") then


punchSound:Clone().Parent = character
end

animator = humanoid:FindFirstChildOfClass("Animator") or
Instance.new("Animator", humanoid)
animationTrack = animator:LoadAnimation(punchAnimation)

mouse.Button1Down:Connect(function()
if debounce then return end
debounce = true

if animationTrack then
animationTrack:Play()
end

local sound = character:FindFirstChild("PunchSound")


if sound then sound:Play() end

local root = character:FindFirstChild("HumanoidRootPart")


if root then
local punchPart = Instance.new("Part")
punchPart.Size = Vector3.new(3, 4, 3)
punchPart.Transparency = 1
punchPart.CanCollide = false
punchPart.Anchored = true
punchPart.CFrame = root.CFrame * CFrame.new(0, 0, -2)
punchPart.Parent = workspace

local connection
connection = punchPart.Touched:Connect(function(hit)
local targetHumanoid = hit.Parent and
hit.Parent:FindFirstChild("Humanoid")
if targetHumanoid and hit.Parent ~= character then
RemoteEvent:FireServer(targetHumanoid, 15) -- 15 de
dano
end
end)

game:GetService("Debris"):AddItem(punchPart, 0.3)
task.delay(0.3, function()
connection:Disconnect()
end)
end

task.wait(0.5)
debounce = false
end)
end)

You might also like