I am trying to make a script that gives a player a tool when they pick up a rock but it just doesn't do anything

You can write your topic however you want, but you need to answer these questions:
I am trying to make a script that gives a player a tool when they pick up a rock.
But it just doesn’t do anything, no errors or messages.
I tried printing but it didn’t print at all
Script:

while true do
	if rockvalue >0 then
		if toolgiven == false then
			print("Tool Given!")
			toolgiven = true
			local clone = game.ServerStorage.Tool:Clone()
			clone.Parent = player.Backpack
			clone.name = "Rock"
		end
	elseif rockvalue == 0 then
		if toolgiven == true then
		local tool = player.Backpack.Rock
		if tool == nil then
			local character = game.Workspace:WaitForChild(player.name)
			if character then
				local tool = character:WaitForChild("Rock")
			end
		end
		tool:Destroy()
		toolgiven = false
		end
	end
	wait()
end