- What do you want to achieve? Keep it simple and clear!
I want to make it so it does not double the pushing every time I use the ability
- What is the issue? Include screenshots / videos if possible!
Everytime I use my ability it doubles the push force
Here is the full script
local Configuration = script.Parent:WaitForChild('Configuration')
local Uis = game:GetService('UserInputService')
local Mouse = game:GetService('MouseService')
local Character = script.Parent
local Root = Character:WaitForChild('HumanoidRootPart')
local durationM1 = 1
local Ability1 = 15
local canM1 = true
local CanAbility1 = true
local hitboxMod = require(game.ReplicatedStorage.HitBox)
local Ability2DMG = .5
local Ability1DMG = .5
local M1Dmg = 15
local AllLocked = false
local M1Anim = Character.Humanoid:LoadAnimation(Configuration.Animations.M1)
local XslashAnim = Character.Humanoid:LoadAnimation(Configuration.Animations.XSLASH)
function Ability1() -- ABILITY 1
if CanAbility1 and AllLocked == false then
if Configuration.Stats.Linked_Sword.Value == true then
CanAbility1 = false
XslashAnim:Play(0)
local hitTble = {}
local hitTble2 = {}
local hitTble3 = {}
AllLocked = true
XslashAnim:GetMarkerReachedSignal("HITBOX"):Connect(function()
local atch = Instance.new("Attachment")
atch.Parent = Character.HumanoidRootPart
local hitbox = hitboxMod.create(atch.WorldCFrame*CFrame.new(0,0,-3), Vector3.new(6, 5, 4), 0.125)
hitbox.Touched:Connect(function(hit)
local victim = hit.Parent
if victim:FindFirstChildWhichIsA("Humanoid") and not table.find(hitTble, victim) and victim ~= Character then
table.insert(hitTble, victim)
print(hitTble)
hitbox.BrickColor = BrickColor.new("Lime green")
-- print(victim)
game.ReplicatedStorage.Events.Damage:FireServer(victim,20)
end
end)
task.wait()
end)
XslashAnim:GetMarkerReachedSignal("HITBOX2"):Connect(function()
local atch = Instance.new("Attachment")
atch.Parent = Character.HumanoidRootPart
local hitbox = hitboxMod.create(atch.WorldCFrame*CFrame.new(0,0,-3), Vector3.new(6, 5, 4), 0.125)
hitbox.Touched:Connect(function(hit)
local victim = hit.Parent
if victim:FindFirstChildWhichIsA("Humanoid") and not table.find(hitTble2, victim) and victim ~= Character then
table.insert(hitTble2, victim)
print(hitTble2)
hitbox.BrickColor = BrickColor.new("Lime green")
-- print(victim)
game.ReplicatedStorage.Events.Damage:FireServer(victim,20)
end
end)
task.wait()
end)
XslashAnim:GetMarkerReachedSignal("BIGHITBOX"):Connect(function()
local atch = Instance.new("Attachment")
atch.Parent = Character.HumanoidRootPart
local hitbox = hitboxMod.create(atch.WorldCFrame*CFrame.new(0,0,-3), Vector3.new(7.5, 5, 6), 0.125)
hitbox.Touched:Connect(function(hit)
local victim = hit.Parent
if victim:FindFirstChildWhichIsA("Humanoid") and not table.find(hitTble3, victim) and victim ~= Character then
table.insert(hitTble3, victim)
print(hitTble3)
hitbox.BrickColor = BrickColor.new("Lime green")
-- print(victim)
game.ReplicatedStorage.Events.Damage:FireServer(victim,35)
end
end)
task.wait()
end)
XslashAnim:GetMarkerReachedSignal("PUSH"):Connect(function()
local mass = Root.AssemblyMass
local force = Vector3.new(0,0,-3000*2)*mass
local vf2 = Instance.new("VectorForce")
vf2.ApplyAtCenterOfMass = true
vf2.Attachment0 = Root.RootAttachment
vf2.Force = force
vf2.Parent = Root
task.wait(.01)
vf2:Destroy()
end)
XslashAnim:GetMarkerReachedSignal("BIGPUSH"):Connect(function()
local mass = Root.AssemblyMass
local force = Vector3.new(0,0,-4000*2)*mass
--local force = Vector3.new(0,0,-2*2)*mass
local vf2 = Instance.new("VectorForce")
vf2.ApplyAtCenterOfMass = true
vf2.Attachment0 = Root.RootAttachment
vf2.Force = force
vf2.Parent = Root
task.wait(.01)
vf2:Destroy()
end)
task.wait(XslashAnim.Length+0.05)
AllLocked = false
task.wait(1)
CanAbility1 = true
end
end
end
function Slash() -- M1 ABILITY
--[[local Speed = 40
local Force = 80000
local TotalForce = Force
local KnockBack = Instance.new("BodyVelocity")
KnockBack.Parent = part.Parent:FindFirstChild("HumanoidRootPart")--part is the target of the knockback/ the opponent
KnockBack.MaxForce = Vector3.new(TotalForce,TotalForce,TotalForce)
KnockBack.Velocity = Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * Speed -- based on the direction YOUR character is facing.]]
if canM1 and AllLocked == false then
if Configuration.Stats.Linked_Sword.Value == true then
print("Swing")
canM1 = false
M1Anim:Play(0)
local hitTble = {}
AllLocked = true
M1Anim:GetMarkerReachedSignal("HITBOX"):Connect(function()
local atch = Instance.new("Attachment")
atch.Parent = Character.HumanoidRootPart
local hitbox = hitboxMod.create(atch.WorldCFrame*CFrame.new(0,0,-3), Vector3.new(6, 5, 4), 0.125)
hitbox.Touched:Connect(function(hit)
local victim = hit.Parent
if victim:FindFirstChildWhichIsA("Humanoid") and not table.find(hitTble, victim) and victim ~= Character then
table.insert(hitTble, victim)
print(hitTble)
hitbox.BrickColor = BrickColor.new("Lime green")
-- print(victim)
game.ReplicatedStorage.Events.Damage:FireServer(victim,M1Dmg)
end
end)
task.wait()
end)
task.wait(M1Anim.Length+0.05)
AllLocked = false
task.wait(durationM1-M1Anim.Length-0.05)
canM1 = true
end
end
end
Uis.InputBegan:Connect(function(input)
if (Uis:GetFocusedTextBox()) then return end
if input.KeyCode == Enum.KeyCode.E then
Ability1()
elseif input.KeyCode == Enum.KeyCode.Q then
print("Ability 2")
elseif input.KeyCode == Enum.KeyCode.R then
print("Ability 3")
end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
Slash()
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.