Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- variables
- local CanDamage = false -- variable for wether it can damage or no
- local M1 = 1 --what M1 animation it will be
- local CanAttack = true --variable for wether it can attack or no. so basically a cooldown
- -- get stuff
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:wait()
- if character == nil then
- player.CharacterAdded:Wait()
- character = player.Character
- end
- local M1HITBOX = character:WaitForChild("Right Arm") --hitboxes
- local M2HITBOX = character:WaitForChild("Left Arm")
- local M3HITBOX = character:WaitForChild("Left Leg")
- local hum = character:WaitForChild("Humanoid")
- local UIS = game:GetService("UserInputService")
- local StunValue = character:WaitForChild("StunValue")
- local Animtable = {
- ["M1"] = hum:LoadAnimation(game.ReplicatedStorage.Anims.Core.M1s.M1),
- ["M2"] = hum:LoadAnimation(game.ReplicatedStorage.Anims.Core.M1s.M2),
- ["M3"] = hum:LoadAnimation(game.ReplicatedStorage.Anims.Core.M1s.M3),
- ["M4"] = hum:LoadAnimation(game.ReplicatedStorage.Anims.Core.M1s.M4)
- }
- Animtable.M1.Looped = false
- Animtable.M2.Looped = false
- Animtable.M3.Looped = false
- Animtable.M4.Looped = false
- local CharValue = character:WaitForChild("CharValue")
- local M1Remote = game.ReplicatedStorage.Remotes.Core.M1sRemote -- getting remote
- local function onInputBegan(input, gameProcessed)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- print("M1 Value is", M1)
- print("CanAttack Is", CanAttack)
- print("CanDamage is", CanDamage)
- if CanAttack == true and StunValue.Value == false then -- activates if theres no cooldown and your not stunned
- CanAttack = false
- print("M1ed")
- print("M1 Value is", M1)
- print("CanAttack Is", CanAttack)
- print("CanDamage is", CanDamage)
- if M1 == 1 then
- print("m1 is 1 now :D")
- Animtable.M1:Play()
- print("played animation")
- StunValue.Value = true
- CanAttack = false
- task.wait(0.283)
- if CanDamage == false then
- CanDamage = true
- M1Remote:FireServer(character, hum)
- --print("M1 Touched")
- end
- Animtable.M1.Stopped:Connect(function()
- StunValue.Value = false
- CanAttack = true
- print("M1Stopped")
- print("Can Attack is", CanAttack)
- M1 = 2
- CanDamage = false
- end)
- end
- if M1 == 2 then
- Animtable.M2:Play()
- StunValue.Value = true
- CanAttack = false
- task.wait(0.267)
- if CanDamage == false then
- CanDamage = true
- M1Remote:FireServer(character, hum)
- --print("m2 touched")
- end
- Animtable.M2.Stopped:Connect(function()
- StunValue.Value = false
- CanAttack = true
- M1 = 3
- CanDamage = false
- end)
- end
- if M1 == 3 then
- Animtable.M3:Play()
- StunValue.Value = true
- CanAttack = false
- task.wait(0.267)
- if CanDamage == false then
- CanDamage = true
- M1Remote:FireServer(character, hum)
- end
- --tells server that it got hit
- end
- Animtable.M3.Stopped:Connect(function()
- StunValue.Value = false
- CanAttack = true
- M1 = 4
- CanDamage = false
- end)
- if M1 == 4 then
- Animtable.M4:Play()
- StunValue.Value = true
- CanAttack = false--changes walkspeed
- task.wait(.3) --waits until the Hit part of the animation
- if CanDamage == false then
- CanDamage = true
- M1Remote:FireServer(character, hum)
- end
- --tells server that it got hit
- end
- Animtable.M4.Stopped:Connect(function()
- StunValue.Value = false--does smthn when the animation is done
- task.wait(2) --cooolddown
- --print(CanAttack)
- --print(M1)
- --print(CanDamage)
- CanAttack = true
- M1 = 1 --resets back to first M1
- CanDamage = false
- end)
- end
- end
- end
- game:GetService("UserInputService").InputBegan:Connect(onInputBegan)
- M1Remote.OnClientEvent:Connect(function(Eplr, Ehum)
- print("Recieved server to client")
- end)
Advertisement
Add Comment
Please, Sign In to add comment