I tried to script some skill thing but it just gone so weird. what is wrong with this script?
the error says It can’t find a humanoidRootPart in PLAYER, Not a character. It was never supposed to be a player, and i tried changing a method but all i could do didnt work as well. it kept saying that humanoidrootpart does not exist on player, even through I wanted it to check Character, not a player. error starts on line 91 btw. “HumanoidRootPart is not a valid member of Player “Players.ritousmirror””
local tool = script.Parent
local character = tool.Parent
if character:IsA("Backpack") then
character = tool.Parent.Parent.Character
print(character.Parent)
print(character)
end
local LeapEvent = tool:WaitForChild("Leap")
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character.PrimaryPart
print(character.Parent.Name)
local reaperAnimation = tool:WaitForChild("Reaper")
local animTrack = humanoid:LoadAnimation(reaperAnimation)
local cooldown = false
LeapEvent.OnServerEvent:Connect(function(target)
print("leaper script activated")
if cooldown == false and humanoid.Health > 1 and character.HumanoidRootPart.Anchored == false and not target:FindFirstChild("IsPlayer") then
cooldown = true
print("running leap script")
tool.leapcool.Value = 60
print(rootPart)
if game.Players:FindFirstChild(character.Name):FindFirstChild("HumanoidRootPart") then
rootPart.Anchored = true
rootPart.CFrame = CFrame.lookAt(rootPart.Position,target.HumanoidRootPart.Position)
tool.Blade.PointLight.Enabled = true
tool.Blade.PointLight1.Enabled = true
-- Play the Reaper animation
animTrack.Priority = Enum.AnimationPriority.Action4
animTrack:Play()
tool.Blade.equip2:Play()
tool.Blade.Trail.Enabled = true
tool.Blade.Trail1.Enabled = true
-- Wait for the windup time
task.wait(0.7)
tool.Blade.Windup:Play()
-- Calculate the direction to the target
local targetPosition = target.HumanoidRootPart.Position
local direction = (targetPosition - rootPart.Position).Unit
wait(0.1)
tool.Blade.PointLight.Enabled = true
tool.Blade.PointLight1.Enabled = true
tool.Blade.smash:Play()
-- Teleport the user 40 studs in the direction of the target
local newPosition = rootPart.Position + direction * 25
rootPart.CFrame = CFrame.new(newPosition)
tool.Blade.Trail.Enabled = false
tool.Blade.Trail1.Enabled = false
if target.Parrying.Value == true then
tool.Blade.pry:Play()
wait(6)
character.Sanity.Value -= 30000000
rootPart.Anchored = false
else
tool.Blade.Slash1:Play()
target.Humanoid.Health -= 350
local plr = game.Players:GetPlayerFromCharacter(character)
if plr:FindFirstChild("leaderstats") then
plr.leaderstats["dmg"].Value += 350
end
tool.Parent.Humanoid.Health += 50
wait(0.2)
character.HumanoidRootpart.Anchored = false
end
task.wait(60)
cooldown = false
else
local newrootPart = game.Players:FindFirstChild(character.Name).Character:FindFirstChild("HumanoidRootPart")
newrootPart.Anchored = true
newrootPart.CFrame = CFrame.lookAt(newrootPart.Position, target.HumanoidRootPart.Position)
tool.Blade.PointLight.Enabled = true
tool.Blade.PointLight1.Enabled = true
-- Play the Reaper animation
animTrack.Priority = Enum.AnimationPriority.Action4
animTrack:Play()
tool.Blade.equip2:Play()
tool.Blade.Trail.Enabled = true
tool.Blade.Trail1.Enabled = true
-- Wait for the windup time
task.wait(0.7)
tool.Blade.Windup:Play()
-- Calculate the direction to the target
local targetPosition = target.HumanoidRootPart.Position
local direction = (targetPosition - newrootPart.Position).Unit
wait(0.1)
tool.Blade.PointLight.Enabled = true
tool.Blade.PointLight1.Enabled = true
tool.Blade.smash:Play()
-- Teleport the user 40 studs in the direction of the target
local newPosition = newrootPart.Position + direction * 25
newrootPart.CFrame = CFrame.new(newPosition)
tool.Blade.Trail.Enabled = false
tool.Blade.Trail1.Enabled = false
if target.Parrying.Value == true then
tool.Blade.pry:Play()
wait(6)
character.Sanity.Value -= 30000000
newrootPart.Anchored = false
else
tool.Blade.Slash1:Play()
target.Humanoid.Health -= 350
local plr = game.Players:GetPlayerFromCharacter(character)
if plr:FindFirstChild("leaderstats") then
plr.leaderstats["dmg"].Value += 350
end
tool.Parent.Humanoid.Health += 50
wait(0.2)
newrootPart.Anchored = false
end
task.wait(60)
cooldown = false
end
end
end)