This is a repost because I wasn’t getting a replies on my previous post. I made s script for an attack in my game that makes you teleport through the boss if your camera is facing the boss and close enough to the boss. There are two animation parts, the preattack (the character getting ready to attack, will play no matter what) and the attack (plays if your camera is close enough and facing the boss, the animation that isn’t working). Loadedcutp2 is currently set to Action priority but I tried setting it to Action4 but it still did not work.
Heres the script (loadedcutp2 is the animation that doesn’t work)
if input.KeyCode == Enum.KeyCode.E then
local stunned = player.Character:GetAttribute("Stunned")
local debouncewait = false
local debounce = 0
if not debouncewait and (stunned == false or stunned == nil) then
debouncewait = true
player.Character.Humanoid.WalkSpeed = 0
local loadedCutp1 = player.Character.Humanoid:LoadAnimation(cutp1)
loadedCutp1:Play()
local camera = workspace.CurrentCamera
local rayorigin = camera.CFrame.Position
local rayDirection = camera.CFrame.LookVector * 100
local rayparams = RaycastParams.new()
rayparams.FilterDescendantsInstances = {player.Character, player.Character.sword}
rayparams.FilterType = Enum.RaycastFilterType.Exclude
wait(1.5)
local rayresults = workspace:Raycast(rayorigin, rayDirection, rayparams)
if rayresults and (rayresults.Instance.Parent == workspace.BossModel or rayresults.Instance.Parent.Parent == workspace.BossModel) then
humanoid.RootPart.CFrame = CFrame.new(workspace.BossModel.Torso.Position) * CFrame.new(-10,0,-2)
local loadedCutp2 = player.Character.Humanoid:LoadAnimation(cutp2)
loadedCutp2:Play()
wait(2)
else
print("no results")
end
player.Character.Humanoid.WalkSpeed = 16
wait(debounce)
debouncewait = false
end
end