Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UserInputService = game:GetService("UserInputService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Players = game:GetService("Players")
- local Debris = game:GetService("Debris")
- local Workspace = game:GetService("Workspace")
- local HitboxModule = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("HitboxModule"))
- local Remotes = ReplicatedStorage:WaitForChild("Remotes")
- local Player = Players.LocalPlayer
- local Character = Player.Character or Player.CharacterAdded:Wait()
- local Humanoid: Humanoid = Character:WaitForChild("Humanoid")
- local Animator: Animator = Humanoid:WaitForChild("Animator")
- local AnimPrefix = "rbxassetid://"
- local Data = {
- Punch = {
- OnDebounce = false;
- DebounceTime = 0.5;
- OnNum = 1;
- MaxNum = 3;
- HitPlayers = {};
- Animations = {
- [1] = "114477525064186",
- [2] = "75082777380705",
- [3] = "71003130513655",
- }
- },
- }
- local function PlayAnim(Id: string)
- local AnimId = AnimPrefix..Id
- local Animation = Instance.new("Animation")
- Animation.AnimationId = AnimId
- local AnimTrack = Animator:LoadAnimation(Animation)
- AnimTrack:Play()
- end
- UserInputService.InputBegan:Connect(function(Input: InputObject, GameProcessedEvent: boolean)
- if GameProcessedEvent then return end
- if Input.UserInputType == Enum.UserInputType.MouseButton1 then
- local SelectedChar, CharDataTable = Remotes.GetCharacterInfo:InvokeServer()
- if SelectedChar and CharDataTable and Data.Punch.OnDebounce ~= true then
- Data.Punch.OnDebounce = true
- if Data.Punch.OnNum + 1 > Data.Punch.MaxNum then
- Data.Punch.OnNum = 1
- else
- Data.Punch.OnNum += 1
- end
- PlayAnim(Data.Punch.Animations[Data.Punch.OnNum])
- local Hitbox = HitboxModule.CreateHitbox(Player, "Block", Vector3.new(5, 5, 5))
- Debris:AddItem(Hitbox, 0.1)
- Hitbox.Touched:Connect(function(Hit: BasePart)
- if Hit.Parent:FindFirstChildOfClass("Humanoid") then
- local HitPlayer = Players:GetPlayerFromCharacter(Hit.Parent)
- if HitPlayer and HitPlayer ~= Player then
- local HitChar = Hit.Parent
- local Now = tick()
- if not Data.Punch.HitPlayers[HitPlayer] or Now - Data.Punch.HitPlayers[HitPlayer] >= Data.Punch.DebounceTime then
- Data.Punch.HitPlayers[HitPlayer] = Now
- print(Player.Name .. " Hit Someone!")
- if Data.Punch.OnNum == 3 then
- -- Knockback
- end
- end
- end
- if Hit.Parent.Parent == Workspace:WaitForChild("Dummys") then
- local HitChar = Hit.Parent
- local Now = tick()
- if not Data.Punch.HitPlayers["Dummy"] or Now - Data.Punch.HitPlayers["Dummy"] >= Data.Punch.DebounceTime then
- Data.Punch.HitPlayers["Dummy"] = Now
- print(Player.Name .. " Hit A Dummy!")
- if Data.Punch.OnNum == 3 then
- -- Knockback
- end
- end
- end
- end
- end)
- task.wait(Data.Punch.DebounceTime)
- Data.Punch.OnDebounce = false
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment