(Solved) Tool Only Being Activated Once

Hello,
I am recently getting back into scripting and decided to make a physics gun using an open sourced physics system, but that is not what I am here for. I am having an issue with my tool. For some reason, the function “Tool.Activated” works fine on the first equip. However, once you unequip and re-equip, the entire function just breaks. It doesn’t print “Active”, or anything like that. Here is the script:

local tool = script.Parent
local plr = game:GetService('Players').LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local humanoid = char:WaitForChild('Humanoid')
local anims = {
	["Idle"] = humanoid:LoadAnimation(script:WaitForChild('Idle')),
	["Use"] = humanoid:LoadAnimation(script:WaitForChild('Use'))
}


tool.Unequipped:Connect(function()
	plr.PlayerScripts:FindFirstChild('Dragger').Enabled = false
	anims.Idle:Stop()
end)

tool.Equipped:Connect(function()
	anims.Idle:Play()
end)


tool.Activated:Connect(function() -- function breaks after unequip, does not print active or anything
	print('active')
	plr.PlayerScripts:FindFirstChild('Dragger').Enabled = true
	anims.Use:Play()
	print(plr.PlayerScripts:FindFirstChild('Dragger').Enabled)
end)

Any help would be appreciated.

Are you getting a error? If so whats the error?

I have fixed the issue, I overlooked a fatal flaw and now it works properly. Thanks for the interest! The way I fixed it was deleting the “plr.PlayerScripts:FindFirstChild(‘Dragger’).Enabled = false” line in the “unequipped” function.

Set your post as solved then. Dont leave it open

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.