after M1s 1,2,3,4, when it loops back to 1 it stops anchoring. So like Click, Click, Click, Click (anchors fine), Cooldown, Click Click Click Click (stops anchoring)
local rs = game:GetService("ReplicatedStorage")
local Tweeninfo = TweenInfo.new(0.3, Enum.EasingStyle.Exponential, Enum.EasingDirection.In, 0, false)
local TS = game:GetService("TweenService")
rs.DamageDealer.OnServerEvent:Connect(function(plr, attackcycle, cooldown)
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {plr.Character}
local rayDistance = 10 --// 3 studs
local origin = plr.Character:FindFirstChild("HumanoidRootPart").Position --// Position of the player
local direction = plr.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * rayDistance --// Direction the player is looking * distance
local raycast = workspace:Raycast(origin, direction ,Params)
print(raycast)
print(plr.Character:FindFirstChild("Head").Orientation.X)
if attackcycle == 1 then
plr.Character:FindFirstChild("HumanoidRootPart").Anchored = true
local Football = game:GetService("ReplicatedStorage").Football:Clone()
Football.Parent = workspace
Football.Position = plr.Character:WaitForChild("Right Leg").Position
local FootballTween = TS:Create(Football, Tweeninfo, {["Position"]=(raycast and raycast.Position or origin + direction)})
FootballTween:Play()
FootballTween.Completed:Connect(function()
Football:Destroy()
task.wait(0.2)
plr.Character:FindFirstChild("HumanoidRootPart").Anchored = false
end)
end
if attackcycle == 2 then
plr.Character:FindFirstChild("HumanoidRootPart").Anchored = true
local Football = game:GetService("ReplicatedStorage").Football:Clone()
Football.Parent = workspace
Football.Position = plr.Character:WaitForChild("Left Leg").Position
local FootballTween = TS:Create(Football, Tweeninfo, {["Position"]=(raycast and raycast.Position or origin + direction)})
FootballTween:Play()
FootballTween.Completed:Connect(function()
Football:Destroy()
task.wait(0.2)
plr.Character:FindFirstChild("HumanoidRootPart").Anchored = false
end)
end
if attackcycle == 3 then
plr.Character:FindFirstChild("HumanoidRootPart").Anchored = true
local Football = game:GetService("ReplicatedStorage").Football:Clone()
local SpecialTweeninfo = TweenInfo.new(0.15, Enum.EasingStyle.Exponential, Enum.EasingDirection.In, 0, false)
Football.Parent = workspace
Football.Position = plr.Character:WaitForChild("Right Leg").Position
local FootballTween = TS:Create(Football, SpecialTweeninfo, {["Position"]=(raycast and raycast.Position or origin + direction)})
FootballTween:Play()
FootballTween.Completed:Connect(function()
FootballTween:Play()
task.wait(0.3)
Football:Destroy()
task.wait(1)
plr.Character:FindFirstChild("HumanoidRootPart").Anchored = false
end)
end
if attackcycle == 4 then
plr.Character:FindFirstChild("HumanoidRootPart").Anchored = true
local Football = game:GetService("ReplicatedStorage").Football:Clone()
local SpecialTweeninfo = TweenInfo.new(0.2, Enum.EasingStyle.Exponential, Enum.EasingDirection.In, 0, false)
Football.Parent = workspace
Football.Position = plr.Character:WaitForChild("Right Leg").Position
local FootballTween = TS:Create(Football, SpecialTweeninfo, {["Position"]=(raycast and raycast.Position or origin + direction)})
FootballTween:Play()
FootballTween.Completed:Connect(function()
FootballTween:Play()
task.wait(0.2)
Football:Destroy()
task.wait(0.3)
plr.Character:FindFirstChild("HumanoidRootPart").Anchored = false
end)
end
--detects if it hit a part of a character with a humanoid
if raycast and raycast.Instance.Parent:FindFirstChild("Humanoid") then
local hum = raycast.Instance.Parent:FindFirstChild("Humanoid")
local char = hum.Parent
local humanoid = char:FindFirstChild("Humanoid")
char:FindFirstChild("HumanoidRootPart").Anchored = true
if attackcycle == 1 or 2 then
humanoid:TakeDamage(5)
elseif attackcycle == 3 then
humanoid:TakeDamage(10)
elseif attackcycle == 4 then
humanoid:TakeDamage(15)
end
task.wait(0.5)
char:FindFirstChild("HumanoidRootPart").Anchored = false
end
end)