I’m attempting to make a sword, When I got to the animation part it wouldnt work.
I have tried printing the Humanoid Variable. And yes it prints Humanoid.
There seems to be no issues it just doesnt want to work.
Script Type: Server Script
Script:
--//Defining CanHit
local CanHit = script.Parent.CanHit
--//Defining Parent
local Parent = script.Parent
--//Defining Animation to play later
local Animation = Instance.new("Animation")
Animation.Parent = script.Parent
Animation.AnimationId = "rbxassetid://5790806333" --Sword Animation
--//Defining Character
local Player = script.Parent.Parent.Parent
local Humanoid = Player.Character.Humanoid
--//Loading Animation
wait(1.2) --//Added wait due to error, Humanoid didnt load in completely causing bugs.
print(Humanoid) --//Returns Humanoid
local LoadedAnimation = Humanoid:LoadAnimation(Animation)
print(LoadedAnimation) --//Returns Animation
--//Making a Hit function, this will be the main function. We will call it later when we need it
function Hit()
if Player.Name == "brodywth" then
LoadedAnimation:Play()
print(Player) --//For now prints the Player.
else Player:Kick("Dont use admin to get tools")
end end
--//Making a function that will toggle CanHit.
function AllowHit()
CanHit.Value = true
end
--//Making a function that will toggle CanHit, this time it will turn off
function NotAllowHit()
CanHit.Value = false
end
--//Event Listeners
Parent.Equipped:Connect(AllowHit)
Parent.Unequipped:Connect(NotAllowHit)
Parent.Activated:Connect(Hit)