Tool.Activated not firing?

Hello, when I try to use the Tool.Activated function, it doesnt detect any sort of activation being made but it should?

Here are the scripts

Local:

local plr = game.Players.LocalPlayer

local tool = script.Parent
local event = script.RemoteEvent

tool.Activated:Connect(function()
	print("activated")
	event:FireServer(plr)
end)

It does not print activated

Server Script:

local animFolder = script.Parent.Parent:WaitForChild("Animations")
local slash1 = animFolder.Slash1
local slash2 = animFolder.Slash2
local slash3 = animFolder.Slash3

local debounce = false

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
	print("yes")
	local char = plr.Character
	local humanoid = char:FindFirstChild("Humanoid")

	if humanoid then
		local animTrack1 = humanoid:LoadAnimation(slash1)
		animTrack1.Priority = Enum.AnimationPriority.Action

		local animTrack2 = humanoid:LoadAnimation(slash2)
		animTrack2.Priority = Enum.AnimationPriority.Action

		local animTrack3 = humanoid:LoadAnimation(slash3)
		animTrack3.Priority = Enum.AnimationPriority.Action

		local sounds = {
			script.Parent.Parent.Handle.Slash1,
			script.Parent.Parent.Handle.Slash2,
			script.Parent.Parent.Handle.Slash3
		}

		local currentAnimationIndex = 1

		print("activated")
		if debounce == true then return end
		debounce = true
		sounds[currentAnimationIndex]:Play()
		currentAnimationIndex += 1
		if currentAnimationIndex > 3 then
			currentAnimationIndex = 1
		end
		if currentAnimationIndex == 1 then
			animTrack3:Stop()
			task.wait()
			animTrack1:Play()
			script.Parent.Parent.Handle.Trail.Enabled = true
			task.wait(.5)
			script.Parent.Parent.Handle.Trail.Enabled = false
			print("done")

		elseif currentAnimationIndex == 2 then
			animTrack1:Stop()
			task.wait()
			animTrack2:Play()
			script.Parent.Parent.Handle.Trail.Enabled = true
			task.wait(.5)
			script.Parent.Parent.Handle.Trail.Enabled = false
			print("done2")

		elseif currentAnimationIndex == 3 then
			animTrack2:Stop()
			task.wait()
			animTrack3:Play()
			script.Parent.Parent.Handle.Trail.Enabled = true
			task.wait(.5)
			script.Parent.Parent.Handle.Trail.Enabled = false
			print("done3")

		end
		
		task.delay(.25, function()
			debounce = false
		end)
	end
end)

Same here, nothing is being printed.

Here are the tool’s behaviour settings.
image

If anyone knows the problem, please help me.

1 Like

is there a handle? if not disable requireshandle

Yes, there a handle in the tool

is it named “Handle”?

thirtycharlim

Yes, it’s named Handle

djdjdjd

Try to move the RemoteEvent in ReplicatedStorage, and not in the script.

Already tried that, still didnt work.

A small suggestion, Remote Events in local scripts already take the player, so you can remove plr and do event:FireServer()

1 Like

is the localscript in StarterPlayerScripts?

EDIT: oh i didn’t see script.Parent

Try move the local script as child of Tool, not Handle.
image

It’s not in the handle?

thirtycharlim

Can you show us the child and parent of inside the tool?

Local script is inside the tool and then the script and remote event are both inside it. This isn’t causing the problem though.

How the player receive the tool?
When he joins or if he click or touch something?

There’s an amulet which the player activates, and that works with .Activated function but this doesnt. Then the player transforms and receive this sword.

set the runcontext of the script to client instead of legacy

Didn’t do anything.

thirtycharlim

Hello, just tested this out myself:

And it works.
Try restarting your studio.
If restarting studio hasn’t worked since last time, then I suggest remaking the tool but keeping the script. It’s a quick and easy way to restart mistakes in properties you may have edited.

Also, I suggest moving your event out of your tool and into replicated storage.
Not to bash anyone’s scripting method here but if this tool where to be re-used its more efficient to have one server code handle every tool.

1 Like