Tool grip not changing when swung

Hello developers,

My goal is to change the weapons grip when the sword is swung. To create a better swing effect.

My problem is that for some reason, it doesn’t change. No errors pop up, and it doesn’t break anywhere. In which I assume that the script is reasonable, it just won’t run.

Here is my code (yes very janky I know. I will fix that later.) :

local tool = script.Parent

local debounce = false

local SwingDetector = tool:WaitForChild("Swing")

tool.Activated:Connect(function()
	if SwingDetector.Value == true and debounce == false then
		debounce = true
		wait(0.8)
		tool.GripForward = Vector3.new(-0.5, 0, 0.866)
		tool.GripPos = Vector3.new(-0.4, 0.1, -1.7)
		tool.GripRight = Vector3.new(0, 1, -0)
		tool.GripUp = Vector3.new(0.866, -0, 0.5)
		wait(0.16)
		tool.GripForward = Vector3.new(-1, 0, -0)
		tool.GripPos = Vector3.new(-0.4, 0.1, -1.7)
		tool.GripRight = Vector3.new(0, 1, -0)
		tool.GripUp = Vector3.new(-0, 0, 1)
		wait(0.2)
		debounce = false
		SwingDetector.Value = false
	end
end)

Anything helps.

Have you tried putting prints in to confirm the logic flows as you expect?

1 Like

I thought of it, but I didn’t. I will do that rn.

Update: It works the 1st time, not any other time though.

As this is an animation , sort of, I would set a wait between each tool.Grip… statement to slow the whole process down ( to help with the visual aspects) and make sure I have a print of the before and after values.

You set the value of SwingDetector to false when the animation is finished and don’t change it back, and because the animation only plays when SwingDetector is true, it won’t activate again after the first use.

1 Like