Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --//Local script for Punching
- local Player = game:GetService("Players").LocalPlayer
- local rp = game:GetService("ReplicatedStorage")
- local Punch = rp:WaitForChild("Punch")
- local UIS = game:GetService("UserInputService")
- local debounce = false
- local cooldown = .75
- UIS.InputBegan:Connect(function(input,IsTyping)
- if IsTyping then
- return
- elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
- if workspace:FindFirstChild(Player.Name.." Stand") then
- if debounce == false then
- debounce = true
- Punch:FireServer()
- wait(cooldown)
- debounce = false
- end
- end
- end
- end)
- --//Server Script for Punching
- local rp = game:GetService("ReplicatedStorage")
- local Punch = rp:WaitForChild("Punch")
- local Debris = game:GetService("Debris")
- local damage = 10
- local currentAtk = 0
- Punch.OnServerEvent:Connect(function(Player)
- local Character = Player.Character
- local Humanoid = Character:WaitForChild("Humanoid")
- local HumanoidRP = Character:WaitForChild("HumanoidRootPart")
- local Stand = workspace:FindFirstChild(Player.Name.." Stand"):WaitForChild("Dummy")
- local folder = Instance.new("Folder",workspace)
- folder.Name = Player.Name.." Stand Punch"
- Debris:AddItem(folder,.5)
- if Stand then
- currentAtk = currentAtk + 1
- local prevWeld = Stand:WaitForChild("HumanoidRootPart"):WaitForChild("Stand Weld")
- prevWeld:Destroy()
- Stand:WaitForChild("HumanoidRootPart").CFrame = HumanoidRP.CFrame * CFrame.new(0,-.5,-2)
- local weld = Instance.new("ManualWeld")
- weld.Name = "Stand Weld"
- weld.Part0 = Stand:WaitForChild("HumanoidRootPart")
- weld.Part1 = HumanoidRP
- weld.C0 = Stand:WaitForChild("HumanoidRootPart").CFrame:inverse() * HumanoidRP.CFrame
- weld.Parent = weld.Part0
- if currentAtk == 1 then
- local Hand = Stand:WaitForChild("LeftHand")
- local animControl = Stand:WaitForChild("AnimControl")
- local Punch = animControl:LoadAnimation(script:WaitForChild("LeftPunch"))
- Punch:Play()
- local HitBox = script:WaitForChild("HitBox"):Clone()
- HitBox.CFrame = Hand.CFrame
- HitBox.Parent = folder
- local Pweld = Instance.new("Weld")
- Pweld.Part0 = HitBox
- Pweld.Part1 = Hand
- Pweld.C0 = HitBox.CFrame:inverse() * Hand.CFrame
- Pweld.Parent = Pweld.Part0
- HitBox.Touched:Connect(function(Hit)
- if Hit:IsA("Part") or Hit:IsA("MeshPart") then
- if Hit.Parent ~= Character then
- local EHumanoid = Hit.Parent:FindFirstChild("Humanoid")
- if EHumanoid then
- HitBox:Destroy()
- local sound = Instance.new("Sound",folder)
- sound.SoundId = "rbxassetid://2174934844"
- sound.Volume = 1
- sound:Play()
- Debris:AddItem(sound,.5)
- EHumanoid:TakeDamage(damage)
- end
- end
- end
- end)
- wait(.5)
- local prevWeld = Stand:WaitForChild("HumanoidRootPart"):WaitForChild("Stand Weld")
- prevWeld:Destroy()
- Stand:WaitForChild("HumanoidRootPart").CFrame = HumanoidRP.CFrame * CFrame.new(2,0,2)
- local weld = Instance.new("ManualWeld")
- weld.Name = "Stand Weld"
- weld.Part0 = Stand:WaitForChild("HumanoidRootPart")
- weld.Part1 = HumanoidRP
- weld.C0 = Stand:WaitForChild("HumanoidRootPart").CFrame:inverse() * HumanoidRP.CFrame
- weld.Parent = weld.Part0
- elseif currentAtk == 2 then
- local Hand = Stand:WaitForChild("RightHand")
- local animControl = Stand:WaitForChild("AnimControl")
- local Punch = animControl:LoadAnimation(script:WaitForChild("RightPunch"))
- Punch:Play()
- local HitBox = script:WaitForChild("HitBox"):Clone()
- HitBox.CFrame = Hand.CFrame
- HitBox.Parent = folder
- local Pweld = Instance.new("Weld")
- Pweld.Part0 = HitBox
- Pweld.Part1 = Hand
- Pweld.C0 = HitBox.CFrame:inverse() * Hand.CFrame
- Pweld.Parent = Pweld.Part0
- HitBox.Touched:Connect(function(Hit)
- if Hit:IsA("Part") or Hit:IsA("MeshPart") then
- if Hit.Parent ~= Character then
- local EHumanoid = Hit.Parent:FindFirstChild("Humanoid")
- if EHumanoid then
- HitBox:Destroy()
- local sound = Instance.new("Sound",folder)
- sound.SoundId = "rbxassetid://2174934844"
- sound.Volume = 1
- sound:Play()
- Debris:AddItem(sound,.5)
- EHumanoid:TakeDamage(damage)
- end
- end
- end
- end)
- wait(.5)
- local prevWeld = Stand:WaitForChild("HumanoidRootPart"):WaitForChild("Stand Weld")
- prevWeld:Destroy()
- Stand:WaitForChild("HumanoidRootPart").CFrame = HumanoidRP.CFrame * CFrame.new(2,0,2)
- local weld = Instance.new("ManualWeld")
- weld.Name = "Stand Weld"
- weld.Part0 = Stand:WaitForChild("HumanoidRootPart")
- weld.Part1 = HumanoidRP
- weld.C0 = Stand:WaitForChild("HumanoidRootPart").CFrame:inverse() * HumanoidRP.CFrame
- weld.Parent = weld.Part0
- else
- currentAtk = 1
- local Hand = Stand:WaitForChild("LeftHand")
- local animControl = Stand:WaitForChild("AnimControl")
- local Punch = animControl:LoadAnimation(script:WaitForChild("LeftPunch"))
- Punch:Play()
- local HitBox = script:WaitForChild("HitBox"):Clone()
- HitBox.CFrame = Hand.CFrame
- HitBox.Parent = folder
- local Pweld = Instance.new("Weld")
- Pweld.Part0 = HitBox
- Pweld.Part1 = Hand
- Pweld.C0 = HitBox.CFrame:inverse() * Hand.CFrame
- Pweld.Parent = Pweld.Part0
- HitBox.Touched:Connect(function(Hit)
- if Hit:IsA("Part") or Hit:IsA("MeshPart") then
- if Hit.Parent ~= Character then
- local EHumanoid = Hit.Parent:FindFirstChild("Humanoid")
- if EHumanoid then
- HitBox:Destroy()
- local sound = Instance.new("Sound",folder)
- sound.SoundId = "rbxassetid://2174934844"
- sound.Volume = 1
- sound:Play()
- Debris:AddItem(sound,.5)
- EHumanoid:TakeDamage(damage)
- end
- end
- end
- end)
- wait(.5)
- local prevWeld = Stand:WaitForChild("HumanoidRootPart"):WaitForChild("Stand Weld")
- prevWeld:Destroy()
- Stand:WaitForChild("HumanoidRootPart").CFrame = HumanoidRP.CFrame * CFrame.new(2,0,2)
- local weld = Instance.new("ManualWeld")
- weld.Name = "Stand Weld"
- weld.Part0 = Stand:WaitForChild("HumanoidRootPart")
- weld.Part1 = HumanoidRP
- weld.C0 = Stand:WaitForChild("HumanoidRootPart").CFrame:inverse() * HumanoidRP.CFrame
- weld.Parent = weld.Part0
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment