I have this script inside of a sword in the StarterGear, The player RigType is set to R15
The animation is made for R15
The Animation was uploaded.
Script:
Tool = script.Parent
Handle = Tool:WaitForChild("Handle")
local BaseUrl = "rbxassetid://"
Players = game:GetService("Players")
Debris = game:GetService("Debris")
RunService = game:GetService("RunService")
DamageValues = {
BaseDamage = 6,
SlashDamage = 20,
}
--For R15 avatars
Animation = 566593606
Damage = DamageValues.BaseDamage
Sounds = {
Slash = Handle:WaitForChild("Slash"),
Hit = Handle:WaitForChild("Hit"),
Unsheath = Handle:WaitForChild("Unsheath")
}
ToolEquipped = false
Tool.Enabled = true
function TagHumanoid(humanoid, player)
local Creator_Tag = Instance.new("ObjectValue")
Creator_Tag.Name = "creator"
Creator_Tag.Value = player
Debris:AddItem(Creator_Tag, 2)
Creator_Tag.Parent = humanoid
end
function UntagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do
if v:IsA("ObjectValue") and v.Name == "creator" then
v:Destroy()
end
end
end
function Blow(Hit)
if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped then
return
end
local character = Hit.Parent
if character == Character then
return
end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid.Health == 0 then
return
end
local player = Players:GetPlayerFromCharacter(character)
if player and (player == Player) then
return
end
UntagHumanoid(humanoid)
TagHumanoid(humanoid, Player)
humanoid:TakeDamage(Damage)
end
function Attack()
Damage = DamageValues.SlashDamage
Sounds.Slash:Play()
Sounds.Hit:Play()
if Humanoid then
local Track = Humanoid.Animator:LoadAnimation(script.attack)
Track:Play()
end
end
Tool.Enabled = true
LastAttack = 0
function Activated()
if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
return
end
Tool.Enabled = false
Attack()
--wait(0.5)
Damage = DamageValues.BaseDamage
local SlashAnim = (script.attack)
Tool.Enabled = true
end
function CheckIfAlive()
return (((Player and Player.Parent and Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent) and true) or false)
end
function Equipped()
Character = Tool.Parent
Player = Players:GetPlayerFromCharacter(Character)
Humanoid = Character:FindFirstChildOfClass("Humanoid")
Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("HumanoidRootPart")
if not CheckIfAlive() then
return
end
ToolEquipped = true
Sounds.Unsheath:Play()
end
function Unequipped()
ToolEquipped = false
end
Tool.Activated:Connect(Activated)
Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(Unequipped)
Connection = Handle.Touched:Connect(Blow)
This is the Roblox Classic Sword script, but with some modifications I might be missing something in the script, but I can’t seem to figure it out and I don’t get any errors in the workspace.
The sword plays the slash and hit sounds and deals damage it just doesn’t play the animation.