Easy Scripting Help

Heyyo, I wanted to make a basic tool, but it’s currently not working

Nothing prints, and the tool doesn’t swing either. It’s a server script.

I’ve tried to look here for myself, but I don’t just want to copy scripts.

local db = true
local swing = script.Parent.Parent
local function Swinged(player)
	local anim = script.Parent:WaitForChild("Animation")
	if anim.AnimationId == "6307477770" then
		db = false
		wait(0.1)
		
		anim:Play()
		db = true
		print(player.Name.."swung the tool")
	end
	end
swing.Activated:Connect(Swinged)

.

there is no player variable when activating a tool. Instead, make a new player variable like this in the function:

local player = script.Parent.Parent.Parent
2 Likes