Attribute value not changing

script.Parent.Touched:Connect(function(part)
	if debounce == false then
		debounce = true
		local player = players:GetPlayerFromCharacter(part:FindFirstAncestorWhichIsA("Model"))
		if player then
			player:SetAttribute("Buildmode" , false)

		end
		debounce = false
	end
end)

My problem is that the value does not change despite no errors showing up in the output and the script being a ServerScript

Is this a local script or a global one?
If its a local one the attribute will change, but only for the local player, and not for the server or anyone else.

it’s a global script. :shallow_pan_of_food:

i know im 2 years late, but this should work

script.Parent.Touched:Connect(function(part)
    local h = part.Parent:FindFirstChildOfClass("Humanoid")

	if debounce or not h then return end

		debounce = true
		local player = game.Players:FindFirstChild(player.Name)

		if player then
			player:SetAttribute("Buildmode" , false)
		end

		debounce = false
	end
end)