Sword not playing when in Starter Pack

  1. What do you want to achieve? I want to make a working sword.

  2. What is the issue? When the player does not pick the tool up off the ground it doesn’t play or acknowledge the fact that I press down

  3. What solutions have you tried so far? I looked on the dev forum but it wasn’t anything specific


local Saber = script.Parent.Handle
local player = game.Players.LocalPlayer
local canswing = true
local cooldown = 1

Saber.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 6
	end
end)

local function AnimationPlay()
	local char = player.Character or player.CharacterAdded:Wait()
	local humanoid = char.Humanoid
	local animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://6694231346"
	local animator = humanoid:FindFirstChildOfClass("Animator")
	local animTrack = animator:LoadAnimation(animation)
	animTrack:Play()
	print(char)
end

script.Parent.Activated:Connect(function()
	if canswing then 
		canswing = false
		AnimationPlay()
		wait(cooldown)
		canswing = true
	end
end)

Also just a little more information: I’m using an already functional local script from one of my other games hints the saber part, and also that worked just fine.

What do you mean by this? Also the changes would only be made to the client side only, which wouldn’t effect anything from the Server’s Side

Well, maybe instead of this:

local animator = humanoid:FindFirstChildOfClass("Animator")
local animTrack = animator:LoadAnimation(animation)

, you can do this:

humanoid:LoadAnimation(animation)

I was saying it doesn’t acknowledge the fact that I’m pressing the tool, because I have a line of code that prints when I press down