Hello, I was going about my business scripting a knife but it seems to not work. The problem is the animation will not play.
Here is my script (it is the local script called “Client”)
--Main
local knife = script.Parent.Parent
local handle = knife:WaitForChild("Handle")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
--folders
local animationsFolder = knife:WaitForChild("Animations")
local eventsFolder = knife:WaitForChild("Events")
local functionsFolder = knife:WaitForChild("Functions")
local scriptsFolder = knife:WaitForChild("Scripts")
local soundsFolder = knife:WaitForChild("Sounds")
--scripts
local serverScript = scriptsFolder:WaitForChild("Server")
local clientScript = scriptsFolder:WaitForChild("Client")
local moduleScript = scriptsFolder:WaitForChild("Module")
--animation
local swingAnimation = animationsFolder:WaitForChild("Slash")
local animationTrack = humanoid:LoadAnimation(swingAnimation)
--sounds
local hit = soundsFolder:WaitForChild("Hit")
local swoosh = soundsFolder:WaitForChild("Swoosh")
local stab = soundsFolder:WaitForChild("Stab")
local equip = soundsFolder:WaitForChild("Equip")
local unequip = soundsFolder:WaitForChild("Unequip")
--handle children (important)
local decal = handle:WaitForChild("Skin")
--local functions
local function onEquip()
--play equip sound
end
local function onUnequip()
--play unequip sound
end
local function onActivation()
--play swoosh sound
if swoosh then
swoosh:Play()
end
--play swing animation
animationTrack:Play()
--if hit, play hit sound
--if hit = player, play stab sound
--give damage
end
--events
knife.Equipped:Connect(onEquip)
knife.Unequipped:Connect(onUnequip)
knife.Activated:Connect(onActivation)
Here is my explorer.
